<SCRIPT LANGUAGE="JavaScript">
function sc1(){ document.getElementById("Div1").style.top=(document.documentElement.scrollTop+(document.documentElement.clientHeight-document.getElementById("Div1").offsetHeight)/2)+"px"; document.getElementById("Div1").style.left=(document.documentElement.scrollLeft+(document.documentElement.clientWidth-document.getElementById("Div1").offsetWidth)/2)+"px"; document.getElementById("Div1").style.position:="absolute";
} </SCRIPT> window.onscroll=sc1(); //滾動(dòng)條事件
<div id="Div1" class="div" style="width: 240px; height:90px" align="center">正中...</div>
主要的代碼 都是上面的了!
|
|