HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
<html>
<head>
<title>Universal vertical center with CSS</title>
<style>
.greenBorder {border: 1px solid green;} /* just borders to see it */
</style>
</head>
<body>
<div class="greenBorder" style="display: table; height: 400px; #position: relative; overflow: hidden;">
<div style=" #position: absolute; #top: 50%;display: table-cell; vertical-align: middle;">
<div class="greenBorder" style=" #position: relative; #top: -50%">
any text<br/>
any height<br/>
any content, for example generated from DB<br/>
everything is vertically centered
</div>
</div>
</div>
</body>
</html>
4 个回复
卫东
赞同来自:
对于垂直对齐,有点困难:
这里
http://www.jakpsatweb.cz/css/c ... .html
石油百科
赞同来自:
注意:它还适用于伪元素: after 和: before.
您也可以在此阅读:
http://css-tricks.com/centerin ... ents/
您可以在这里查看:
http://jsfiddle.net/y0081cgL/1/
龙天
赞同来自:
如果可能的话,将其捆绑在一起
高度和宽度为 100% 和
td 在中间的垂直对齐中安装它,在中心的文本对齐
莫问
赞同来自: