div始终位于屏幕底部

简述:

在拖拉过程中,是的某个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">


你可能感兴趣的:(div始终位于屏幕底部)