【发布时间】:2015-04-15 23:58:03
【问题描述】:
我无法将文本块置于页面中心。 这是我要居中的文本:
<div id="DIRECTIONS">
<h2>Use the keyboard to rotate a face of the cube in a clockwise direction!
<br>Hold down the shift key to rotate the desired face counter-clockwise.
<br>Use your mouse to rotate the cube and zoom in and out.</h2>
</div>
在我的级联样式表中,我有以下内容:
#DIRECTIONS{
position:absolute;
top:80px;
left:31.5%;
text-align:center;
}
使用上面的代码,当它全屏时,文本(有点)在我的浏览器中居中。当我更改浏览器的大小时,文本变得笨拙地移动并且根本没有居中。我知道我需要指定文本的高度和宽度,但有没有更简单的方法呢?或者有人可以帮我看看这个文本的高度和宽度是多少?
谢谢
【问题讨论】: