简体   繁体   中英

Bootstrap Fixed Navbar Behavior

Can somebody explain what is going on here?

I'm using bootstrap 3.3.7.

Why are .container elements invisible?

    <!-- Navbar -->
    <div class="navbar navbar-inverse navbar-fixed-top">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">Big Brother</a>
        </div>
        <div class="navbar-collapse">
            <ul class="nav navbar-nav">
                <li><a href="#" href="/">Home</a></li>
                <li><a href="#" href="/message">Messages</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li>something</li>
            </ul>
        </div>
    </div>
    <div class="container">
        <h2>Invisible</h2>
    </div>

Your <h2> is not invisible, it's hiding behind your navbar.

You're using a navbar that uses fixed positioning. This takes it out of the normal document flow where it doesn't take up space so the elements after it begin to flow as if it wasn't there.

If you add padding-top: 50px; to <body> you will see your <h2> .

If you read through the Bootstrap Navbar Docs you'll notice a callout that says Body padding required .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM