2015-05-29 132 views
0

我想按鈕(導航欄切換)在我測試的任何時候都可見:http://jsfiddle.net/KyleMit/m49Bb/,它的工作原理是50/50。按鈕是所有時間。如果我點擊按鈕菜單在一瞬間彈出並消失。Bootstrap導航欄切換常開

也許更容易理解: 1.點擊按鈕。 2.參見菜單2s。 3.再次,你看不到菜單。

我用引導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; 
} 
+1

什麼?我不明白......這裏有甚麼問題嗎? –

+0

請說明更好,似乎工作正常。 – lmgonzalves

+0

對不起。我的英語:(更好? – viko

回答

1

在bootstrap.css 選擇:

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

(刪除顯示:塊重要) 和我的css:

.navbar.always-open .navbar-collapse.collapse { 
    display: none; 
} 
.navbar.always-open .navbar-collapse.in { 
    display: block; 
} 
0

試試這個:只刪除數據的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>