怎么让DIV定位在浏览器水平位置中间

来源:百度知道 编辑:UC知道 时间:2024/05/13 19:43:54
#topbar{
width: 950px;
height:336px;
position:absolute;
margin-left:20px;
margin-top:132px;
z-index:2000;}
怎么让它定位在浏览器正中央,不使用这个margin:0 auto;
谢谢,SARURI你提供的这个样式它不兼容IE8和火狐,有没有可以兼容这两种浏览器的

SARURI你好,有时间吗?我那个DIV定位居中还有点问题,可以的话QQ聊下,谢谢951427167

我叫他上下左右都剧中!
<div style="background:blue;position:absolute;left:expression((body.clientWidth-50)/2);top:expression((body.clientHeight-50)/2);width:50;height:50"></div>
...
唉...你非要不要用magin 0auto; 还要讨论兼容性问题...怎么说好呢再提供个js方法,css的我没考虑到合适的 为什么不让用那个呢?

把如下代码加入<body>区域中

<DIV id=L1 style="HEIGHT: 107px; LEFT: 341px; POSITION: absolute; TOP: 585px; WIDTH: 205px; Z-INDEX: 1">

<TABLE bgColor=#ffffff border=1 borderColorDark=#ffffff borderColorLight=#000000 cellPadding=0 cellSpacing=0 width="100%">

<TR>

<TD height=1 width=178>41414141414141414741414::</TD>

<TD align=middle onclick="L1.style.visibility='hidden'"

style="CURSOR: hand" width=21>х</TD></TR>

<TR vAlign=top>

<TD colSpan=2

height=91>21321321231

</TD></TR>&