CSS - Bootstrap - Navbar宽度缩小移动按钮

时间:2015-05-08 21:42:25

标签: css twitter-bootstrap

How to change navbar/container width? Bootstrap 3 在此之后我非常困惑。 我在CSS中还是比较新的,所以我还在玩bootstrap。

我在导航栏div外面添加了一个div来包含总宽度。

.navbar-outer {
  width:1000px;
  margin-left: auto;
  margin-right: auto;
}

效果很好,但只要我缩小浏览器范围。 "移动"按钮不再显示。有什么关于变化的建议,同时保持css中的所有内容完好无损?这是针对bootstrap 3.3.4。

以下完整代码:

  <nav class="navbar navbar-default">
    <div class="navbar-outer">
      <div class="container-fluid">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="#">Brand</a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
          <ul class="nav navbar-nav">
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"> Action <span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
                <li class="divider"></li>
                <li><a href="#">One more separated link</a></li>
              </ul>
            </li>
          </ul>
          <ul class="nav navbar-nav navbar-right">
              <form class="navbar-form navbar-left" role="search">
                <div class="form-group">
                  <input type="text" class="form-control" placeholder="Search">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
              </form>
            <li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><img src="testimage.jpg" style="width: 25px; height: 25px;" alt="..." class="img-circle"> Me <span class="caret"></span></a>
              <ul class="dropdown-menu" role="menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
              </ul>
            </li>
          </ul>
        </div><!-- /.navbar-collapse -->
      </div><!-- /.container-fluid -->
      </div>
    </nav>

1 个答案:

答案 0 :(得分:0)

我认为可能是您使用px设置宽度,这意味着无法触发Bootstrap导航栏的折叠功能。我认为它在768px时崩溃。

使用min-width和max-width:

.navbar-outer {
  max-width:1000px;
  min-width:767px;
  margin-left: auto;
  margin-right: auto;
}

http://jsfiddle.net/frank184/m3n3r1tg/