-2
這是我的腳本jQuery腳本不工作
$(window).bind('scroll', function() {
if ($(window).scrollTop() > 20) {
$('#navmenu').css('position', 'fixed');
$('#navmenu').css('background', 'black');
$('#navmenu').css('width', '100%');
$('#navmenu').css('margin-left', '0%');
$('#navmenu').css('opacity', '0.9');
$('#navmenu').css('height', '35%');
$('#navmenu').css('margin-top', '2.2%');
} else {
$('#navmenu').css('position', 'relative');
$('#navmenu').css('background', 'transparent');
$('#navmenu').css('opacity', '1');
$('#navmenu').css('margin-top', '0px');
}
});
,在這裏你可以看到我的問題。 PROBLEM 腳本在大帖子中效果很好,但在小帖子中,我有這個bug。如何解決這個問題..
「不工作」是_永遠_足夠的問題說明。 –
此代碼顯示了您如何非常低效地執行操作。設置課程! '$('#navmenu')。toggleClass(「fixedMenu」,$(window).scrollTop()> 20);'並設置規則。 – epascarello
你可以在鏈接上看到我的問題..當我嘗試滾動它只是閃爍..並確定,我設置了一個類... – Zzuum