Css垂直对齐 [英] Css Vertical Alignment
本文介绍了Css垂直对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在div里面有单列顺序的按钮。按钮计数可更改。我想垂直对齐按钮。 vertical-align:middle不工作。我该如何做?
I have buttons with single column order inside div. Button count is changeable. I want to align buttons vertically. "vertical-align:middle" is not work. How can I do that?
Div的高度是固定的。 http://jsfiddle.net/WmD3L/
如何垂直对齐按钮?
Div height is fixed. http://jsfiddle.net/WmD3L/ How can I align theese buttons vertically?
推荐答案
如果按钮有固定的高度,您可以使用line-height将文本放在中间。
If the button has a fixed height you can use line-height to place the text in the middle.
例如
#button {
height: 50px;
line-height: 50px; //Must be the same as height to vertically align to the middle
}
也使用
#button {
display: table-cell;
vertical-align: middle;
}
但我不认为这可以交叉浏览器。
But I don't think this works cross browser unfortunately.
这篇关于Css垂直对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文