[英]Position fixed related parent container
另一种方法是更新。
尝试给出固定的div
z-index: 10;
和页脚div position: relative; z-index: 11
position: relative; z-index: 11
这应该使页脚重叠固定div。
然后它不是位置问题:修复,也许你可以定义一个最小高度到你的身体(或主要包装,如果有的话),以避免短页问题
我结合了css和js:
$(document).ready(function () {
var $sidebar = $(".register-box"),
$window = $(window),
$content = $("#content"),
docHeight = $(document).height();
var entered = false;
$window.scroll(function () {
if ($window.height() < 795 && docHeight - $window.scrollTop() < 785) {
entered = true;
var pos = $sidebar.offset();
$sidebar.css('position', 'absolute').css('top', ($content.height() - ($sidebar.height() + 40)) + 'px');
}
else {
if (entered) {
entered = false;
$sidebar.css({
top: "",
left: "",
position: "fixed"
});
}
}
});
});
代码不是最终的,并且数字是硬编码的,但是可以正常运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.