This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--hmtl標題列--> | |
<nav> | |
<ul> | |
<li><a href="/archive">Archive</a></li> | |
<li><a href="/events">Events</a></li> | |
<li><a href="/contact">Contact</a></li> | |
<ul> | |
</nav> | |
<!--JQuery--> | |
$(window).scroll(function () { | |
if ($(window).scrollTop() >= 300) { | |
$('nav').addClass('fixed-header'); | |
} | |
else { | |
$('nav').removeClass('fixed-header'); | |
} | |
}); |
標提列使用nav包覆 很簡單直接使用jquery scrollTop判斷
if(移動超過多少)
{
新增標提列
}
else{remove
}
我上面是用300因為我的banner是300高度
當然可以用的效果不只這個,各位自己去摸索吧
效果展示如下: