2016-02-10 129 views
1

我有一個導航欄有幾個下拉菜單。它們已被修改,以使用一個容器,以顯示下拉內容4列Bootstrap導航欄未對齊下拉菜單

enter image description here enter image description here

注意,用於在導航欄每個下拉菜單中,在下拉菜單中沒有與所述容器(灰色區域)神韻:。我希望將所有下拉列表與容器對齊。

我試過絕對定位這個,但它不工作得很好,我想知道是否有更好的引導方式做到這一點?

代碼:

<nav class="navbar navbar-inverse navbar-fixed-top"> 
    <div class="container"> 
    <div class="navbar-header"> 
     <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" 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> 
    </div> 
    <div id="navbar" class="navbar-collapse collapse"> 
     <ul class="nav navbar-nav"> 
     <li class="dropdown"> 
      <a href="#" 
      class="dropdown-toggle" 
      data-toggle="dropdown" 
      role="button" aria-haspopup="true" 
      aria-expanded="false"> 
      Dropdown 1 <span class="caret"></span> 
      </a> 
      <div class="dropdown-menu"> 
      <div class="container"> 
       <div class="row"> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       </div> 
      </div> 
      </div> 
     </li> 
     <li class="dropdown"> 
      <a href="#" 
      class="dropdown-toggle" 
      data-toggle="dropdown" 
      role="button" 
      aria-haspopup="true" 
      aria-expanded="false"> 
      Dropdown 1 <span class="caret"></span> 
      </a> 
      <div class="dropdown-menu"> 
      <div class="container"> 
       <div class="row"> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       <div class="col-lg-3"> 
        <ul class="list-unstyled"> 
        <li><a href="#">Action</a></li> 
        <li><a href="#">Another action</a></li> 
        <li><a href="#">Something else here</a></li> 
        <li class="divider" role="separator"></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> 
       </div> 
       </div> 
      </div> 
      </div> 
     </li> 
     </ul> 
    </div> 
    </div> 
</nav> 
+1

我們需要的CSS太... –

+1

作出[小提琴](HTTPS:<div class="container" style="width:...">

或者爲每個屏幕尺寸<div class="container custom-width"> CSS類: //jsfiddle.net/) – Raviteja

+0

你用什麼'css'作爲下拉菜單? – DebRaj

回答

1

您的每一個dropdown-menu包含<div class="container">已經固定width對應的屏幕尺寸。

你應該手動設置容器寬度:

@media (min-width: 768px) { 
    .custom-width { 
    width: ... !important; 
    } 
} 
@media (min-width: 992px) { 
    .custom-width { 
    width: ... !important; 
    } 
} 
@media (min-width: 1200px) { 
    .custom-width { 
    width: ... !important; 
    } 
}