div始终位于屏幕底部

来源:互联网 发布:ug creo 编程 编辑:程序博客网 时间:2024/04/30 16:26

简述:

在拖拉过程中,是的某个div始终位于屏幕底部


代码:

$(function(){// 首先计算屏幕高度var height = document.body.clientHeight;$("#footer").css("top", height)// 拖拉事件计算foot div高度$(window).scroll(function () {    var scrollDiff = document.body.scrollTop //  拖拉处的位移$("#footer").css("top", height + scrollDiff) // 重计算底部位置});})


html中需要使用absolute定位

<footer style="position:absolute;" id="footer">


0 0
原创粉丝点击