不知道問題出在哪里,大家幫忙看看唄<!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>
想要小div在scrollTop得800到2400像素之間時先逐漸變到400px在逐漸變回原來的值
Echo_Chien
2016-08-12 17:44:28