不知道问题出在哪里,大家帮忙看看呗
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
#out{ width:100%; height:3200px;}
#ad{ width:180px; height:100px; position:absolute; background-color:rgba(255,102,51,1);}
</style>
</head>
<body>
<div id="out">
<div id="ad">
</div>
</div>
<script>
window.onscroll=function(){
var ad=document.getElementById("ad")
ad.style.top=document.body.scrollTop+300+"px";
if(document.body.scrollTop>800||document.body.scrollTop<2400){
//alert(ad.offsetHeight)
/* if(document.body.scrollTop>800 && document.body.scrollTop<1600){
ad.style.height=ad.offsetHeight+100+"px"
}
if(document.body.scrollTop>1600&&document.body.scrollTop<2400){
ad.style.height=ad.offsetHeight-100+"px"
}*/
ad.style.height=400+"px"
}
if(document.body.scrollTop>2400||document.body.scrollTop<800){
ad.style.height=100+"px"
}
}
</script>
</body>
</html>
相关分类