猿问

js运动框架为什么不行?

html====
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="style/main.css">
</head>
<body>
<div id="box"></div>

<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>

<br>
</body>
</html>
<script src="js/jquery-1.11.2.js"></script>
<script src="js/demo.js"></script>
css===
*{margin: 0;padding: 0;}
#box{width: 100px;height: 100px;background: red;position: absolute;right: 0;bottom: 0;}

js=====
window.onscroll=function () {
var box=document.getElementById('box');
var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
box.style.top=document.documentElement.clientHeight-box.offsetHeight+scrollTop+"px";
}
为什么不行?

精慕HU
浏览 406回答 1
1回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答