对联广告

老子叫甜甜 提交于 2019-12-25 01:31:57
<style type="text/css">
#main{text-align:center;}
#adver{
    position:absolute;
    left:50px;
    top:30px;
    z-index:2;
}
</style>
<script src="js/scroll.js"></script>
</head>
<body>
<div id="adver"><img src="images/adv.jpg"/></div>
<div id="main"><img src="images/main1.jpg"/><img src="images/main2.jpg"/><img src="images/main3.jpg"/></div>
</body>
var adverTop; //层距页面顶端距离
var adverLeft;
var adverObject; //层对象

function inix(){
   adverObject=document.getElementById("adver"); //获得层对象
   if(adverObject.currentStyle){
   adverTop=parseInt(adverObject.currentStyle.top);
   adverLeft=parseInt(adverObject.currentStyle.left);
}
else{
   adverTop=parseInt(document.defaultView.getComputedStyle(adverObject,null).top);
   adverLeft=parseInt(document.defaultView.getComputedStyle(adverObject,null).left);
    }
}

function move(){
adverObject.style.top=adverTop+parseInt(document.documentElement.scrollTop)+"px";
adverObject.style.left=adverLeft+parseInt(document.documentElement.scrollLeft)+"px";
}  

window.onload=inix;
window.onscroll=move;

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!