bootstrap 3.1.1 navbar不会在手机上崩溃

时间:2014-05-29 20:46:53

标签: css angularjs twitter-bootstrap

我有以下代码。在手机上,导航栏在扩展后不会崩溃,我必须单击按钮才能切换样式。任何想法?

<div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <a ui-sref="default" class="navbar-brand"></a>

                <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
            </div>
            <div class="collapse navbar-collapse" id="navbar-main">
                <ul class="nav navbar-nav">

                    <li ng-repeat="top in topnav" ng-class="{active: isActive(top.view), dropdown:top.subnav.length>=0}">
                        <a ui-sref="{{top.state}}" ng-show="top.subnav.length==0">{{top.name}}</a>
                        <a href="" class="dropdown-toggle" ng-show="top.subnav.length > 0" data-toggle="dropdown">{{top.name}} <b class="caret"></b></a>
                        <ul class="dropdown-menu" ng-show="top.subnav.length > 0">
                            <li ng-repeat="sub in top.subnav">
                                <a ui-sref="{{sub.state}}">{{sub.name}}</a>
                            </li>
                        </ul>
                    </li>

                </ul>
            </div>
        </div>

2 个答案:

答案 0 :(得分:0)

Working Fiddle

只需使用它;

   <div class="navbar navbar-inverse">
            <div class="container">
              <div class="navbar-header">
                <button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
                  <span class="sr-only">Toggle navigation</span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                  <span class="icon-bar"></span>
                </button>
                <a href="#" class="navbar-brand">Project name</a>
              </div>
              <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav">
                  <li class="active"><a href="#">Home</a></li>
                  <li><a href="#about">About</a></li>
                  <li><a href="#contact">Contact</a></li>
                  <li class="dropdown">
                    <a data-toggle="dropdown" class="dropdown-toggle" href="#">Dropdown <b class="caret"></b></a>
                    <ul class="dropdown-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 class="dropdown-header">Nav header</li>
                      <li><a href="#">Separated link</a></li>
                      <li><a href="#">One more separated link</a></li>
                    </ul>
                  </li>
                </ul>
              </div><!--/.nav-collapse -->
            </div>
          </div>

答案 1 :(得分:0)

你包括bootstrap.min.js吗?

下拉和折叠菜单所需。

<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>