垂直对齐A Div

时间:2011-03-31 14:40:56

标签: html css

有没有人有可靠的标记/ CSS在所有浏览器中垂直对齐div? 可以在Firefox中使用以下工作但不能在其他工作中使用..

.parent { display: table; }
.child { display: table-cell; }  /* this panel is to align vertically in the middle*/

1 个答案:

答案 0 :(得分:1)

如果你是垂直对齐简单文本,你可以这样做:

.container { height:300px; line-height:300px }

如果你想垂直对齐div,那么你需要使用一些javascript才能使它适用于所有浏览器。