小屏幕上的Bootstrap 4填充

时间:2019-10-13 12:24:01

标签: twitter-bootstrap bootstrap-4

我正在使用引导程序4,我的导航栏具有注册和登录按钮。我在按钮之间使用了填充以留出空间,在所有屏幕上都很好,但在小屏幕上填充不可见,如此处所示。

enter image description here

这是我的页面html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Register form</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="http://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
    <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script src="http://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
 </head>
 <body>
 
        <!-- Navbar -->
        <nav class="navbar navbar-expand-lg navbar-dark bg-dark bg-company-blue static-top">
            <div class="container">
                <a class="navbar-brand" href="#">
                    <img src="images/logo.png" alt="logo"></a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarResponsive">
                    <ul class="navbar-nav mr-auto">
                        <li class="nav-item">
                            <a class="nav-link" href="#">Home
             
                            <span class="sr-only">(current)</span>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Page 1</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Page 2</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="#">Page 3</a>
                        </li>
                    </ul>
                        <ul class="nav navbar-nav mx-auto">
                        <li class="nav-item pl-lg-1 pr-lg-1 pt-md-1 pb-md-1 pt-sm-1 pb-sm-1">
                            <a class="btn btn-sm align-middle btn-primary custom-btn" href="#">Log in</a>
                        </li>
                        <li class="nav-item pl-lg-1 pr-lg-1 pt-md-1 pb-md-1 pt-sm-1 pb-sm-1">
                            <a class="btn btn-sm align-middle btn-success" href="#">Sign up</a>
                        </li>
                    </ul>

                </div>
            </div>
        </nav>

        <!-- Navbar -->

 </body>
 </html>

1 个答案:

答案 0 :(得分:2)

您只需要使用py-1而不是所有其他其他最底层的类...

        <ul class="nav navbar-nav mx-auto">
            <li class="nav-item pl-lg-1 pr-lg-1 py-1">
                <a class="btn btn-sm align-middle btn-primary custom-btn" href="#">Log in</a>
            </li>
            <li class="nav-item pl-lg-1 pr-lg-1 py-1">
                <a class="btn btn-sm align-middle btn-success" href="#">Sign up</a>
            </li>
        </ul>

https://www.codeply.com/go/GCWzgopP2l