这里是解决办法,
<div style="position:fixed; margin-left:300px; font-size:24px; text-decoration:none; font-weight:bold; font-style:normal;">
<a href="#whatisit">What is it</a>
<a href="#desc">Description</a>
<a href="#faq">FAQ</a>
</div>
<div id="clockbox" style="height:4000px;">
<h1 id="whatisit" style="height:400px;">What is it</h1>
<h1 id="desc" style="height:400px;">Description</h1>
<h1 id="faq" style="height:400px;">FAQ</h1>
</div>
和脚本,
$(window).scroll(function() {
if(parseInt($('#whatisit').offset().top) + $('#whatisit').height() >= ($(window).scrollTop())){
$('a').css('color','blue');
$('a[href="#whatisit"]').css('color','black');
}
else if(parseInt($('#desc').offset().top) + $('#desc').height()>= ($(window).scrollTop())){
$('a').css('color','blue');
$('a[href="#desc"]').css('color','black');
}
else if(parseInt($('#faq').offset().top) + $('#faq').height() >= ($(window).scrollTop())){
$('a').css('color','blue');
$('a[href="#faq"]').css('color','black');
}
});
您可以使用%的高度也甚至不使用它。不管你会得到什么位置。为了更好地理解,我已经指定了高度。
我认为你会得到一个想法,弯曲你的方式。干杯:)。
你有没有看过[jScrollPane API](http://jscrollpane.kelvinluck.com/api.html)?他们可能有些东西可以帮助你。 – peduarte
当然,我做过,但没有一个适合我。 –