Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 页脚未在滚动底部设置高度动画_Javascript_Jquery_Css_Jquery Animate - Fatal编程技术网

Javascript 页脚未在滚动底部设置高度动画

Javascript 页脚未在滚动底部设置高度动画,javascript,jquery,css,jquery-animate,Javascript,Jquery,Css,Jquery Animate,当我向下滚动50px到底部时,我希望页脚填满整个窗口。我试图给它的高度设置动画,但没有效果 HTML jquery $(window).scroll(function(){ var scrollTop = $(this).scrollTop(), docH = $(document).height(), winH = $(this).height(); if(scrollTop + winH >= docH-50){ $('footer').stop().anim

当我向下滚动50px到底部时,我希望页脚填满整个窗口。我试图给它的高度设置动画,但没有效果

HTML

jquery

$(window).scroll(function(){
var scrollTop = $(this).scrollTop(),
    docH = $(document).height(),
    winH = $(this).height();

if(scrollTop + winH >= docH-50){
    $('footer').stop().animate({height:'100%'},'slow');
}else{
    $('footer').stop().animate({height:'50px'},'slow');
}
});

谢谢你

问题是当你说高度时:“100%”就是说50像素的100%

尝试添加

footer { max-height: 100%; }
在css中


它应该能解决你的问题

你能把你的代码放在小提琴上吗?你的意思是50像素在哪里?这是我在CSS中设置的50px吗?我认为jquery将其样式设置为样式属性,所以它否决了我在CSS中设置的样式?
$(window).scroll(function(){
var scrollTop = $(this).scrollTop(),
    docH = $(document).height(),
    winH = $(this).height();

if(scrollTop + winH >= docH-50){
    $('footer').stop().animate({height:'100%'},'slow');
}else{
    $('footer').stop().animate({height:'50px'},'slow');
}
});
footer { max-height: 100%; }