㈠ 通過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>