有幾個方法可以做到這一點,但開始與您可以使用Vertial對齊。這是我一直髮現的CSS中的PITA。
Vertial對齊:
您可以將主容器設置爲display: table-cell;
,然後在搜索DIV使用vertial-align: middle;
。這在老版本的IE中是不受支持的,但是隨着你的響應速度的提高,無論如何你都會有一些額外的刺激。
.menuBar {
display: table;
}
.logo, .search {
display: table-cell;
vertial-align: middle;
}
<div class="menuBar">
<div class="logo">LOGO</div>
<div class="search">SEARCH</div>
</div>
線高度:
#ex6 { height: 5em; line-height: 5em; }
#ex6 * { vertical-align: middle; }
<div id='ex6'>
<div class='lfloat'>lfloat</div>
<div class='rfloat'>rfloat</div>
<input type='checkbox'>
<input type='text'>
<span class='small'>small</span>
<img src='avatar.gif'>
normal
<span class='large'>large</span>
</div>
行高度榜樣,其他人可以在這裏找到 - http://codeincomplete.com/posts/2011/3/20/css_vertical_align/
它導入到一個CMS系統,以及和高度將是不明,所以第一個是偉人,非常感謝! B) 剛剛應用與設計的CSS,它很酷! 祝你工作順利! – 2012-07-17 11:06:33
不客氣。如果有幫助,請接受這是正確的答案。 – SpaceBeers 2012-07-17 11:07:01