2013-08-29 206 views
1

我去了Twitter的引導主頁和複製粘貼下面的菜單:什麼元素是負責中心的菜單項垂直

.navbar.navbar-inverse.navbar-fixed-top 
    .navbar-inner 
    .container/I tried 'margin: 0 auto;' since nav is a display block item but with no luck 
     %button.btn.btn-navbar{"data-target" => ".nav-collapse", "data-toggle" => "collapse", :type => "button"} 
     %span.icon-bar 
     %span.icon-bar 
     %span.icon-bar 
     %a.brand{:href => "./index.html"} Bootstrap 
     .nav-collapse.collapse 
     %ul.nav 
      %li.active 
      %a{:href => "./index.html"} Home 
      %li 
      %a{:href => "./getting-started.html"} Get started 
      %li 
      %a{:href => "./scaffolding.html"} Scaffolding 
      %li 
      %a{:href => "./base-css.html"} Base CSS 
      %li 
      %a{:href => "./components.html"} Components 
      %li 
      %a{:href => "./javascript.html"} JavaScript 
      %li 
      %a{:href => "./customize.html"} Customize 

BUT!我的物品並沒有以他們的方式爲中心,我試着用safari開發者工具玩,但沒有任何運氣!

哪個元素負責垂直居中物件?

enter image description here

編輯:這裏

enter image description here

編輯:這是我在Safari工具看到的.container元素:

enter image description here

enter image description here

+0

你可以看看'display:table-cell'和'vertical-align:middle'就像在http://jsfiddle.net/arunpjohny/Kv3aG/1/ –

回答

1

如果我找到你的話,那麼它是一個有填充的錨點:10px 15px 10px;這是什麼使它垂直和水平中心。

+0

嗨,我添加了另一個截圖 – nevermind

+0

爲什麼你當你想知道錨標籤時,看看容器類嗎? – Mainz007

0

這不是一個居中問題。菜單項應與導航欄本身的高度相同。 您的導航欄上可能有一個太高的元素。