公安部散装汽油规定:CSS中怎么让文本屏幕严格距中?不用JS

来源:百度文库 编辑:神马品牌网 时间:2024/04/29 12:34:08
二个字“居中”怎么样才能在整个浏览器中居中呀?
就是水平和垂直都居中,水平的容易现实,垂直的怎么实现呀?
不要用JS,只用CSS实现~ 还有要在不同的分辨率下都可以~
谢谢~
用CSS,<div>标签呀~

<div style="position:relative;left:expression((parseInt(screen.width)-parseInt(this.style.width))/2-window.screenLeft);top:expression((parseInt(screen.height)-parseInt(this.style.height))/2-window.screenTop);width:200px;height:100;background:#ff9966;text-align:center;line-height:100px;">居中</div>

没用CSS:
<table height=100% width=100% ><tr><td align=center valign=middle>试试</td></tr></table>

<div style="position:relative;left:0;top:0; width:100%; height=100%">
<table width=100% height=100%>
<tr>
<td align=center>居中</td>
</tr>
</table>
</div>