Bootstrap <div class=“navbar navbar-fixed-top”>

落爺英雄遲暮 提交于 2019-12-05 18:01:14

example

<div class="navbar navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container">
          <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="brand" href="./index.html">Bootstrap</a>
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li class="active">
                <a href="./index.html">Home</a>
              </li>
              <li>
                <a href="./getting-started.html">Get started</a>
              </li>

              ...

              <li>
                <a href="./customize.html">Customize</a>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>

or throw

.navbar { 
    max-width: 1170px; /* width of .container */
    margin: 0 auto;
}

into the css

You should have a container class nested inside your navbar

<div class="navbar navbar-fixed-top">
   <div class="container">your menu and logo go here</div>
</div>

That will give you the same width as the body container if you do not have a fluid layout and will give auto margins to the container so it is centered in the middle of the screen. It will also keep the navbar itself at 100%

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!