Bootstrap navbar-toggle总是打开

时间:2015-05-29 13:52:05

标签: javascript css twitter-bootstrap

我想在我测试的任何时候看到按钮(导航栏切换):http://jsfiddle.net/KyleMit/m49Bb/并且它可以50/50工作。按钮是所有时间。如果我点击按钮菜单片刻会弹出并消失。

也许更容易理解: 1.单击按钮。 2.参见菜单2s。 再次,你没有看到菜单。

我使用了Bootstrap v3.3.4

<nav class="navbar navbar-default navbar-static-top always-open" role="navigation">
                <div class="container">
                  <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar" aria-controls="navbar">
                      <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="#">{{projectTitle()}}</a>
                  </div>
                  <div id="navbar" class="navbar-collapse collapse">
                    {{ menu() | raw}}
                  </div><!--/.nav-collapse -->
                </div>
            </nav>

CSS

.navbar.always-open {
    border-radius: 0;
}
.navbar.always-open .navbar-header {
  float: none;
}
.navbar.always-open .navbar-toggle {
  display: block;
}
.navbar.always-open .navbar-collapse {
  border-top: 1px solid transparent;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar.always-open .navbar-collapse.collapse {
  display: none!important;
}
.navbar.always-open .navbar-nav {
  float: none!important;
  margin: 7.5px -15px;
}
.navbar.always-open .navbar-nav>li {
  float: none;
}
.navbar.always-open .navbar-nav>li>a {
  padding-top: 10px;
  padding-bottom: 10px;
}

2 个答案:

答案 0 :(得分:1)

在bootstrap.css中 中选择:

viewWillAppear()

(删除显示:阻止!重要) 在我的CSS中:

.navbar-collapse.collapse{
  height:auto!important;
  padding-bottom:0;
  overflow:visible!important
}

答案 1 :(得分:0)

试试这个:只删除data-toogle值:

<nav class="navbar navbar-default sidebar" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-sidebar-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>
            </div>
            <div class="collapse navbar-collapse" id="bs-sidebar-navbar-collapse-1">
                <ul class="nav">
                    <li class="active"><a href="/Home/Index">Home<span style="font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-home"></span></a></li>
                    <li class="open">
                        <a href="#" class="dropdown-toggle">Reportar <span class="caret"></span><span style="font-size:16px;" class="pull-right hidden-xs showopacity glyphicon glyphicon-file"></span></a>
                        <ul class="dropdown-menu forAnimate" role="menu">
                            <li><a href="#" style="font-size:12px;">b</a></li>
                            <li><a href="#" style="font-size:12px;">c</a></li>
                            <li><a style="font-size:12px;">a</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>