Bootstrap 4导航栏固定顶部问题:为什么会创建空白

时间:2019-04-23 18:42:10

标签: html css3 bootstrap-4

嗨,我在导航栏中遇到了问题 它会创建一个空白:screenshot html代码:

    <div class="header">
    <div class="overlay"></div>
    <nav class="navbar fixed-top navbar-expand-lg navbar-light bg-light">
        <a class="navbar-brand" href="#">Creative Agency</a>
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul class="navbar-nav ml-auto">
                <li class="nav-item active">
                    <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Watch Video</a>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Demo Pages
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="#">Creative Agency</a>
                        <a class="dropdown-item" href="#">Travel Agency</a>
                    </div>
                </li>
                <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Blocks
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                        <a class="dropdown-item" href="#">Menu Pages</a>
                        <a class="dropdown-item" href="#">Haeders</a>
                        <a class="dropdown-item" href="#">Pages</a>
                        <a class="dropdown-item" href="#">Images & Videos</a>
                        <a class="dropdown-item" href="#">Team</a>
                        <a class="dropdown-item" href="#">Counters</a>
                    </div>
                </li>
            </ul>
        </div>
        <ul class="social-links list-unstyled">
            <li><a href="#"><i class="fab fa-twitter"></i></a></li>
            <li><a href="#"><i class="fab fa-facebook-f"></i></a></li>
            <li><a href="#"><i class="fab fa-instagram"></i></a></li>
        </ul>
    </nav>
    <div class="container">
        <div class="heading text-center">
            <h1>We are creative agency</h1>
            <p>Our professional team of designers will help you to create a unique image of your company, which will distinguish it from competitors and attract new customers.</p>
        </div>
    </div>
</div>

如何在不出现此问题的情况下使导航栏固定(在顶部)!

我使用Bootstrap 4

注意:为主体添加padding-top无法解决此问题!

1 个答案:

答案 0 :(得分:0)

我通过addign解决了问题

padding-top: 48px;

到标题!