嗨我試圖實現這個導航欄效果:http://kettlenyc.com/,這樣當我向下滾動導航欄並將動畫轉換爲固定位置時。我已經開始在這裏的代碼,但不能讓動畫工作:http://theturning.co.uk/NOAH/動畫在導航條上的導航條上
我的Jquery看起來像這樣的時刻:
$(function() {
var bar = $('#topbar');
var top = bar.css('top');
$(window).scroll(function() {
if($(this).scrollTop() > 0) {
bar.stop().css({'position' : 'absolute'});
}
if($(this).scrollTop() > 600) {
bar.stop().animate({'top' : '0px'}, 100).css({'position' : 'fixed'});
} else {
bar.stop().animate({'top' : top}, 100);
}
});
});
和CSS:
#topbar {
background: url('../images/bg-topbar.png') left top;
position: absolute;
top: 0;
width: 100%;
height: 50px;
z-index: 999;
padding: 20px 0 20px 0;
}
任何幫助將不勝感激!由於
嘗試動畫的不透明度,將其設置爲0,然後再以動畫爲1 – P1nGu1n 2013-03-10 16:43:57
您好,感謝您的答覆。這將如何幫助將它從靜態位置改變並將其設置爲像Kettle示例一樣的固定位置? – theturning 2013-03-10 20:45:42