stranger5 2016-02-10 13:02 采纳率: 0%
浏览 1561

js里div框缓冲浮动,不知道为什么没有效果,求大神指点!

<!DOCTYPE html>




<br> #div1{width: 100px;height:150px;background: red;position: absolute;right: 0;bottom:0;}<br>
<br> window.onscroll=function(){<br> var oDiv=document.getElementById(&quot;div1&quot;);<br> var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;</p> <pre><code> //oDiv.style.top=document.documentElement.clientHeight-oDiv.offsetHeight+scrollTop+&quot;px&quot;; startMove(document.documentElement.clientHeight-oDiv.offsetHeight+scrollTop); var timer=null; function startMove(iTarget){ var oDiv=document.getElementById(&quot;div1&quot;); clearInterval(timer); timer=setInterval(function(){ var speed=(iTarget-oDiv.offsetTop)/6; var speed=speed&gt;0?Math.ceil(speed):Math.floor(speed); if(oDiv.offsetTop==iTarget) { clearInterval(timer); } else{ oDiv.style.top=oDiv.offsetTop+speed+&quot;px&quot;; } },30); } } &lt;/script&gt; </code></pre> <p></head><br> <body style="height: 2000px"><br> <div id="div1"></div><br> </body><br> </html></p>
  • 写回答

1条回答

  • devmiao 2016-02-10 23:39
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建