我正在使用此代码:
$(window).scroll(function () {
if (($(document).height() - $(window).scrollTop()) <= 500){
$("#content-5").css({
position: 'fixed',
top: 'auto',
bottom: '300px'
});
} else if ($(window).scrollTop() >= 30) {
$("#content-5").css({
position: 'fixed',
top: '30px',
bottom: 'auto'
});
}else{
$("#content-5").css({
position: 'absolute',
top: '30px',
bottom: 'auto'
});
}
});
这是演示
它的工作正常,但我不知道怎么办,那个浮动元素停在页脚。有人可以帮忙吗?
答案 0 :(得分:1)
我已经更新了你的小提琴....改变你的第一块css ......
$("#content-5").css({
position: 'fixed',
top: '0px',
bottom: 'auto'
});