为了账号安全,请及时绑定邮箱和手机立即绑定

想要小div在scrollTop得800到2400像素之间时先逐渐变到400px在逐渐变回原来的值

想要小div在scrollTop得800到2400像素之间时先逐渐变到400px在逐渐变回原来的值

Echo_Chien 2016-08-12 17:44:28
不知道问题出在哪里,大家帮忙看看呗<!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>
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 1704 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信