html====
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="style/main.css">
</head>
<body style="height:1000px">
<p id="box"></p>
</body>
</html>
<script src="js/jquery-1.11.2.js"></script>
<script src="js/demo.js"></script>
css
#box{width: 100px;height: 100px;background: red url() 0 0 no-repeat;position: absolute;bottom: 0;right: 0; }
js
window.onscroll=function () {
var obj=document.getElementById('box');
var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
obj.style.top=document.documentElement.clientHeight-obj.offsetHeight+scrollTop+"px";
}
为什么我滚动一下图片就消失了,而视频是随着滚动的
阿神2017-04-10 15:19:50
使用jQuery
的写法:
$('#box').animate({'top': documentElement.clientHeight - obj.height() + scrollTop + 'px'}, 'slow');