2014-10-28 127 views
0

我正嘗試在導航欄合攏中使用下拉菜單。問題是,當我沒有打開下拉菜單時,一切正常,這意味着我不需要滾動條來查看內容。但是,當下拉菜單切換時,高度不會更改,因此下拉內容不可見。BootStrap 3 - 帶有下拉菜單的導航欄,下拉菜單的擴展名超出了最大高度

如果我不打開下拉:

enter image description here

一切都很好,但是當我打開下拉:我輸了3個菜單隻能滾動,它們是:添加,編輯,刪除

enter image description here

您需要上下滾動。

這是我的CSS代碼:

/* 
* Base structure 
*/ 

/* Move down content because we have a fixed navbar that is 50px tall */ 
body 
{ 
    overflow-y: scroll; 
} 

/* 
* Global add-ons 
*/ 

.custom-button-length 
{ 
    width: 100px; 
} 

.sub-header 
{ 
    padding-bottom: 10px; 
    border-bottom: 1px solid #eee; 
} 

/* 
* Top navigation 
* Hide default border to remove 1px line. 
*/ 
@media (max-width: 767px) 
{ 
    .navbar-fixed-top 
    { 
     position: relative; 
     top: auto; 
    } 

    .navbar-collapse 
    { 
     max-height: none; 
    } 

    body 
    { 
     margin: 0; 
    } 

    .navbar-default 
    { 
     max-height: none; 
    } 
} 

/* 
* Sidebar 
*/ 

/* Hide for mobile, show later */ 
.wrapper 
{ 
    padding-left: 0; 
    -webkit-transition: all 0.5s ease; 
    -moz-transition: all 0.5s ease; 
    -o-transition: all 0.5s ease; 
    transition: all 0.5s ease; 
} 

.wrapper.toggled 
{ 
    padding-left: 250px; 
} 

.wrapper.toggled .sidebar 
{ 
    width: 0px; 
    padding-left: 0px; 
    padding: 0px; 
} 

.sidebar 
{ 
    position: fixed; 
    top: 51px; 
    bottom: 0; 
    left: 0px; 
    z-index: 1000; 
    display: block; 
    padding: 20px; 
    padding-right: 100px; 
    overflow-x: hidden; 
    overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ 
    background-color: #f5f5f5; 
    border-right: 1px solid #eee; 
    -webkit-transition: all 1.0s ease; 
    -moz-transition: all 1.0s ease; 
    -o-transition: all 1.0s ease; 
    transition: all 1.0s ease; 
} 

@media (max-width: 768px) 
{ 
    .sidebar 
    { 
     width: 0px; 
     padding-left: 0px; 
     padding: 0px; 
    } 
} 

/* Sidebar navigation */ 
.nav-sidebar 
{ 
    margin-right: -21px; /* 20px padding + 1px border */ 
    margin-bottom: 20px; 
    margin-left: -20px; 
} 

.nav-sidebar > li > a 
{ 
    padding-right: 20px; 
    padding-left: 20px; 
    position: fixed-top; 
} 

.nav-sidebar > .active > a, 
.nav-sidebar > .active > a:hover, 
.nav-sidebar > .active > a:focus 
{ 
    color: #fff; 
    background-color: #428bca; 
} 


/* 
* Main content 
*/ 

.main 
{ 
    padding: 20px; 
    margin-left: 210px; 
    margin-top:50px; 
    -webkit-transition: all 1.0s ease; 
    -moz-transition: all 1.0s ease; 
    -o-transition: all 1.0s ease; 
    transition: all 1.0s ease; 
} 

@media (max-width: 768px) 
{ 
    .main 
    { 
     margin-left: 0px; 
     margin-top: -20px; 
     padding-top: 20px; 
     -webkit-transition: all 1.0s ease; 
     -moz-transition: all 1.0s ease; 
     -o-transition: all 1.0s ease; 
     transition: all 1.0s ease; 
    } 
} 

.main .page-header 
{ 
    margin-top: 0; 
} 

.main.toggled 
{ 
    padding: 20px; 
    margin-left: 0px; 
    -webkit-transition: all 1.0s ease; 
    -moz-transition: all 1.0s ease; 
    -o-transition: all 1.0s ease; 
    transition: all 1.0s ease; 
} 

/* 
* Placeholder dashboard ideas 
*/ 

.placeholders 
{ 
    margin-bottom: 30px; 
    text-align: center; 
} 
.placeholders h4 
{ 
    margin-bottom: 0; 
} 
.placeholder 
{ 
    margin-bottom: 20px; 
} 
.placeholder img 
{ 
    display: inline-block; 
    border-radius: 50%; 
} 

.graph-container 
{ 
    box-sizing: border-box; 
    width: 850px; 
    height: 450px; 
    padding: 20px 15px 15px 15px; 
    margin: 15px auto 30px auto; 
    border: 1px solid #ddd; 
    background: #fff; 
    background: linear-gradient(#f6f6f6 0, #fff 50px); 
    background: -o-linear-gradient(#f6f6f6 0, #fff 50px); 
    background: -ms-linear-gradient(#f6f6f6 0, #fff 50px); 
    background: -moz-linear-gradient(#f6f6f6 0, #fff 50px); 
    background: -webkit-linear-gradient(#f6f6f6 0, #fff 50px); 
    box-shadow: 0 3px 10px rgba(0,0,0,0.15); 
    -o-box-shadow: 0 3px 10px rgba(0,0,0,0.1); 
    -ms-box-shadow: 0 3px 10px rgba(0,0,0,0.1); 
    -moz-box-shadow: 0 3px 10px rgba(0,0,0,0.1); 
    -webkit-box-shadow: 0 3px 10px rgba(0,0,0,0.1); 
} 

.graph-placeholder 
{ 
    width: 100%; 
    height: 100%; 
    font-size: 14px; 
    line-height: 1.2em; 
} 

.legend table 
{ 
    border-spacing: 5px; 
} 

這是我的HTML代碼:

<div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> 
    <div class="container-fluid"> 
     <div class="navbar-header"> 
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse"> 
       <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="#"> WebStats</a> 
     </div> 
     <div class="navbar-collapse collapse"> 
      <ul class="nav navbar-nav navbar-right"> 
       <li><a href="#">Dashboard</a></li> 
       <li><a href="#">Settings</a></li> 
       <li><a href="#">Profile</a></li> 
       <li><a href="{% url 'WebApp:logout'%}">Logout</a></li> 
      </ul> 
      <ul class="nav navbar-nav navbar-left"> 
       <li><a href="{% url 'WebApp:index'%}">Views</a></li> 

       <li><a href="#toggleMenu">SideBar</a></li> 
       <li class="dropdown"> 
        <a href="#" class="dropdown-toggle" data-toggle="dropdown"> 
         Chart Options 
         <span class="caret"></span> 
        </a> 
        <ul class="dropdown-menu" role="menu" data-no-collapse="true"> 
         <li><a href="{% url 'WebApp:addChart'%}">Add</a></li> 
         <li><a href="{% url 'WebApp:editChart'%}">Edit</a></li> 
         <li><a href="#removeChart">Remove</a></li> 
        </ul> 
       </li> 
      </ul> 
     </div> 
    </div> 
</div> 

我在移動模式下施加最大高度爲None當像素小於768,然而,它仍然需要向下滾動。

回答

1

添加important申報到財產max-height在移動媒體查詢:

.navbar-collapse { 
    max-height: none!important; 
} 
0

首先,沒有必要定義自己的CSS的移動設備。 Twitter的Bootstrap是移動的第一,你只需要按照這Link

希望它會幫助...