<html xmlns=" http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=gb2312" />
<title>自创随滚动条移动的层</title>
<style type="text/css">
.div{width:200pxheight:100pxborder:5px solid #993300line-height:90pxtext-align:centerbackground:#CCCCCCposition:absolutez-index:1000}
</style>
<script type="text/javascript">
function s1(){
var d1=document.getElementById("d1")
d1.style.top=document.documentElement.scrollTop+"px"
d1.style.left=document.documentElement.scrollLeft+"px"
}
function s2(){
var d2=document.getElementById("d2")
d2.style.top=document.documentElement.scrollTop+"px"
d2.style.left=parseInt(document.documentElement.clientWidth+document.documentElement.scrollLeft-d2.offsetWidth)+"px"
//d2.style.left="400px"
}
function s3(){
var d3=document.getElementById("d3")
d3.style.top=parseInt(document.documentElement.clientHeight+document.documentElement.scrollTop-d3.offsetHeight)+"px"
//d3.style.top=document.documentElement.scrollHeight+"px"
d3.style.left=parseInt(document.documentElement.scrollLeft)+"px"
}
function s4(){
var d4=document.getElementById("d4")
d4.style.top=parseInt(document.documentElement.clientHeight+document.documentElement.scrollTop-d4.offsetHeight)+"px"
d4.style.left=parseInt(document.documentElement.clientWidth+document.documentElement.scrollLeft-d4.offsetWidth)+"px"
}
function s5(){
var d5=document.getElementById("d5")
d5.style.top=parseInt(document.documentElement.clientHeight/2+document.documentElement.scrollTop-d5.offsetHeight/2)+"px"
d5.style.left=parseInt(document.documentElement.clientWidth/2+document.documentElement.scrollLeft-d5.offsetWidth/2)+"px"
}
function s(){
s1()s2()s3()s4()s5()
}
window.onscroll=s
window.onresize=s
window.onload=s
</script>
</head><body>
<div style="width:4000pxheight:4000px">
<div id="d1" class="div">左上……</div>
<div id="d2" class="div">右上……</div>
<div id="d3" class="div">左下……</div>
<div id="d4" class="div">右下……</div>
<div id="d5" class="div">居中……</div>
</div>
</body>
</html>
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)