㈠ 通过js弹出的浮动DIV层,居中于窗口中。
把style里面的left和top拿到js里面写
在CSS里面用expression是只有IE支持的 这就是不兼容的东西
<div id="divCenter" align="center" style="position: absolute; z-index: 3; display: none; background-color: #fff;" >
<span style="background-color:Gray; width:390px; height:220px; text-align:center;"><BR /><BR />面板中的内容</span>
</div>
<script language="javaScript">
document.getElementById('divCenter').style.left = (document.body.offsetWidth - 540) / 2;
document.getElementById('divCenter').style.top = (document.body.offsetHeight - 170) / 2 + document.body.scrollTop;
</script>
<a onclick="javascript:document.all.divCenter.style.display='block';">显示该层</a>
㈡ javascript怎么居中
这个来不需要JavaScript就可以源搞定了。
<div style="height:30px; width:100px; text-align:center; line-height:30px;">
Javascript怎么实现让文字居中
</div>