这应该很容易,但是想想处理大脑迷雾吧。
试图创建一个垂直/水平显示页面中心的文本的页面
<html>
<head>
<title>Application error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
<table>
<tr>
<th style="background-color:#FFFFFF;vertical-align: central">
This should be center of page vertcally/horizontally
</th>
</tr>
</table>
</body>
</html>
文本在中间对齐,但在页面顶部对齐--水平中心,但垂直。
试着寻找被称为“大脑冻结”的标签,但没有成功。也许管理员可以在这种情况下做一个
发布于 2013-07-27 13:28:37
使用此设置:
table{
position:relative;
margin:0 auto;
top:50%; /* assign manually */
}
body{
height:100%;
width:100%;
position:absolute;
}
jsFiddle:这里
发布于 2013-07-27 13:16:28
此JSFiddle演示如何以中心对齐。
将您的CSS作为
table {
width:300px;
height:300px;
background-color:#d9d9d9;
position:fixed;
margin-left:-150px; /* half of width */
margin-top:-150px; /* half of height */
top:50%;
left:50%;
}
table th
{
text-align: center;
vertical-align: middle;
}
发布于 2013-07-27 13:19:09
将其更改为vertical-align: middle;
https://stackoverflow.com/questions/17898155
复制相似问题