在动画页脚的同时保持在底部

时间:2014-06-27 11:14:39

标签: javascript jquery html

我有footer#footer,其中包含公司位置。当我用哈希#location加载联系页面时,javascript滚动到页面底部,并进行回调以放大页脚,因为它是重要的元素。当页面保持在底部时,如何增加页脚的大小(因此看起来像页脚推高了内容)。

var hash = window.location.hash;
if (hash=="#location") {
    var scrollpos = $(document).height()-$(window).height()+"px"
    $("body,html").delay(200).animate({
        scrollTop: scrollpos
    }, "slow", function() { exfoot() });
}
function exfoot(){
    var $f = $("footer#footer");
    $f.animate({
        height: $f.height()*2
    }, "slow");
}

1 个答案:

答案 0 :(得分:0)

我将此添加到函数

$("html, body").animate({ scrollTop: $(document).height() }, "slow");

所以看起来

function exfoot(){
    var $f = $("footer#footer");
    $f.animate({
        height: $f.height()*2
    }, "slow");
    $("html, body").animate({ scrollTop: $(document).height() }, "slow");
}

$ f.animate和body的速度,html.animate都必须相同,所以它们同时起作用。