我想知道,当你向下滚动页面时,如何使粘性页眉收缩(带有动画),当页面向上滚动到顶部时,如何使粘性页眉恢复到正常状态.下面是两个需要澄清的例子:
http://themenectar.com/demo/salient/
http://www.kriesi.at/themes/enfold/
我得到的部分,使其固定,但我该怎么做,以缩小我的标题时,用户滚动下来?
万分感谢
我想知道,当你向下滚动页面时,如何使粘性页眉收缩(带有动画),当页面向上滚动到顶部时,如何使粘性页眉恢复到正常状态.下面是两个需要澄清的例子:
http://themenectar.com/demo/salient/
http://www.kriesi.at/themes/enfold/
我得到的部分,使其固定,但我该怎么做,以缩小我的标题时,用户滚动下来?
万分感谢
This should be what you are looking for using jQuery.
$(function(){
$('#header_nav').data('size','big');
});
$(window).scroll(function(){
if($(document).scrollTop() > 0)
{
if($('#header_nav').data('size') == 'big')
{
$('#header_nav').data('size','small');
$('#header_nav').stop().animate({
height:'40px'
},600);
}
}
else
{
if($('#header_nav').data('size') == 'small')
{
$('#header_nav').data('size','big');
$('#header_nav').stop().animate({
height:'100px'
},600);
}
}
});
演示: