<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>jsBOM</title>
<style>
#div1{
width: 100px;
height: 200px;
background-color: #00b3ee;
right: 0;
bottom:0;
position: absolute;
}
body{
height:2000px;
}
</style>
</head>
<body>
<div id="div1">
</div>
</body>
<script>
//js实现div固定在页面底部
window.onscroll=window.onresize=function(){ //onresize解决窗口大小变化时的问题
var scrollTop=document.documentElement.scrollTop||document.body.scrollTop;
var oDiv=document.getElementById('div1');
oDiv.style.top=document.documentElement.clientHeight-oDiv.offsetHeight+scrollTop+'px';
};
confirm('delete?'); //返回true或者false
prompt('请输入你的名字','哈哈'); //返回输入的内容,第二个参数胃初始默认值
</script>
</html>
js实现div固定在下方
最新推荐文章于 2022-06-08 20:27:44 发布