我希望每次向下滚动页面时都会固定一个div框,触摸该框并继续向下滚动,以便在用户看到它后它永远不会消失。
$(window).scroll(function() {
if($('section#top_casino_offer').scrollTop() +
$('section#top_casino_offer').innerHeight() >= $('section#top_casino_offer')[0].scrollHeight) {
console.log('show');
} else {
console.log('hide');
}
});
I made a quick snippet for it here
我尝试了上面的代码,但它不起作用。
希望你能提供帮助。
答案 0 :(得分:0)
您可以像这样指定滚动值,请检查以下代码段:
=IF(LEN(A2)<3,"",IF(UPPER(MID(A2,3,1))="J","X",""))
$(window).scroll(function() {
var y_scroll_pos = window.pageYOffset;
var scroll_pos_test = 90;
// set to whatever you want it to be
if(y_scroll_pos > scroll_pos_test) {
$("#top_casino_offer").css("position","fixed");
}
else
{
$("#top_casino_offer").css("position","relative");
}
});
.outer{
height: 1100px;
background: green;
width: 100%;
}
#yellow{background: yellow;
}
#top_casino_offer {
top: 0;
}
希望这有助于:)