同學(xué)代碼里面看了一下@baka_q提交的代碼,他是沒有用事件循環(huán)綁定,但是他的方法只適合本案例,并且要每個item的的高度都一樣,換到別的案例里面就不適用了。老師的代碼簡潔明了,可以復(fù)用,所以作為初學(xué)者請保持謙遜的態(tài)度為好。
2017-03-09
$("#menu a").click(function(){
$("#menu a").removeClass('current');
$(this).addClass('current');
});
$("#menu a").removeClass('current');
$(this).addClass('current');
});
2017-03-02
var top = $(document).scrollTop();
$(".item").each(function(index){
if(top > $(this).offset().top-200){
$("#menu a").removeClass('current');
$("#menu a").eq(index).addClass('current');
} })
$(".item").each(function(index){
if(top > $(this).offset().top-200){
$("#menu a").removeClass('current');
$("#menu a").eq(index).addClass('current');
} })
2017-03-02
解決 IE6 不支持絕對定位 fixed 以及IE6下被絕對定位的元素在滾動的時候會閃動的問題
/* IE6 hack */
*html,*html body {
background-image:url(about:blank);
background-attachment:fixed;
}
*html #menu {
position: absolute;
top: expression(((e=document.documentElement.scrollTop) ? e : document.body.scrollTop) + 100 + 'px');
}
/* IE6 hack */
*html,*html body {
background-image:url(about:blank);
background-attachment:fixed;
}
*html #menu {
position: absolute;
top: expression(((e=document.documentElement.scrollTop) ? e : document.body.scrollTop) + 100 + 'px');
}
2017-02-23