2013-10-30 59 views

回答

1

只需從here複製並粘貼基礎頂部條示例即可。 在你的HTML將這個,

  1. 刪除頂欄
  2. 的左側或右側部分刪除左右從<ul class="left">' or '<ul class="right">
  3. 刪除標題部分<h1><a href="#">Top Bar Title </a></h1>
  4. @media only screen and (min-width: 58.75em) { 就在}結束標記之前添加

    .top-bar-section ul {display: table; margin: 0 auto;} 
    
    .top-bar-section ul li {display: table-cell;} 
    

這個現在應該離開你的三個鍵,如果你選擇了左側,它應該完全居中

+0

這將導致你當它頂端杆的移動版本喪失功能,請參見下面 – blnc

+0

我的回答我沒有從此失去了任何功能,我已將它運行在3個站點上,並且已在多個瀏覽器和設備上進行了測試。話雖如此,你需要根據你遇到的一般尺寸量身定做。 – Switchfire

0

這裏是最好的解決方案我發現,所有的調整事件的作品。它以基金會5頂級欄元素爲中心。

請注意'包含網格'div類將保持網站框架內的頂部欄導航的寬度,但實際上並不會實現導航元素的居中。

下面的代碼的確如此。

SCSS:

nav.top-bar:not(.expanded) { 
      text-align: center; 
      section.top-bar-section { display: inline-block; } 
          } 

HTML:

<div class="contain-to-grid"> 
    <nav class="top-bar" data-topbar> 
     <ul class="title-area"> 
      <li class="name"> 
       <h1><a href="#"></a></h1> 
      </li> 
      <!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone --> 
      <li class="toggle-topbar menu-icon"><a href="#"><span>Menu</span></a></li> 
     </ul> 

     <section class="top-bar-section"> 
      <ul> 
       <li><%= link_to 'LINK 1', root_path %></li> 
       <li class="divider"></li> 
       <li><%= link_to 'LINK2', link_path %></li> 
       <li class="divider"></li> 
       <li class="has-dropdown"> 
        <%= link_to 'Dropping', "#" %> 
        <ul class="dropdown"> 
         <li><label>Label:</label></li> 
         <li><%= link_to 'DROP 1', drop_path %></li> 
         <li class="divider"></li> 
         <li><%= link_to 'DROP 2', drop_path %></li> 
        </ul> 
       </li> 
      </ul> 
     </section> 
    </nav> 
</div>