简体   繁体   中英

Bootstrap affix on navbar, property is always on (class always active)

I am trying to implement Bootstrap's affixed navbar, like in this example.

Here is a pen of what I have. It seems that the 'affix' class is always activated on the navbar element. That is, when I do

.affix {
   top: 0;
}

The navbar automatically goes to the top on page load, when what I want it to do is be under the name and title. Any ideas on why this could be happening?

EDIT: Fixed the example link

Something like this?

https://codepen.io/anon/pen/mRrBNK

I've just moved the title and sub text and added a class within

<nav class="navbar navbar-default navbar-custom" data-spy="affix" data-offset top="197">      
<div class="navbrand">
  <h1> John Smith</h1></div>
  <h4> Developer and Engineer </h4>

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