2011-04-16 63 views
0

我有我的資產淨值內部結構如下:垂直居中與顯示元素:inline-block的

ul > ((li>a) * 2) 

爲元素的CSS是:

ul {height: 29px; list-style: none;} 
li { 
    display: inline-block; 
    height: 23px; 
    zoom: 1; 
    *display: inline; 
} 

如何垂直居中李的在ul內?
謝謝!
編輯: a元素是李元素的孩子。

回答

0

如果你的身高是固定的,最簡單的解決方案是給li一個3px的上邊距。

備選:

ul { 
    height: 26px; 
    padding-top: 3px; 
    list-style: none; 
} 
0

line-height: 29pxli的應該工作如果文字都在同一行

ul { 
    height: 50px; 
    background: #eee; 
    border: 1px solid #000; 
} 

li { 
    display: inline-block; 
    zoom: 1; 
    *display: inline; 
    line-height: 50px; /* same as UL height */ 
}