我试图复制这种粘性的粘性效果:http://tbwachiatdayla.com/ 我希望菜单在某个高度变得粘稠。我怎样才能做到这一点?位置:固定;在顶部:100px高度让我们说
答案 0 :(得分:1)
我正在浏览粘性菜单并遇到了这个问题:http://jsfiddle.net/vyHQC/
$(document).scroll(function() {
var y = $(document).scrollTop(), //get page y value
header = $("#block-menu");
if(y >= 300) {
header.css({position: "fixed", "top" : "0", "left" : "0"});
} else {
header.css("position", "relative");
}
});
其他人写了代码,所以我不会信任,但我会发布答案。 Position fixed on a certain point