所以我使用 jQuery 将页脚绝对定位在内容不多的页面上。
我注意到的问题是页脚加载到它的正常位置,然后在 jQuery 添加类时明显跳到页面底部。无论如何要绕过这个跳跃?
/* Position footer bottom of all pages */
positionFooter: function () {
var windowHeight = jQuery(window).height();
var content = jQuery("#content").height() + jQuery("#footer-wrapper").height();
if (windowHeight > content){
jQuery("#content").css("padding-bottom", jQuery("#footer-wrapper").height());
jQuery("#footer-wrapper").addClass("fixed-bottom");
}
}
我正在使用 window.load:
jQuery(window).load(function()
最佳答案
这个怎么样
positionFooter: function ()
{
var windowHeight = jQuery(window).height();
var content = jQuery("#content").height() + jQuery("#footer-wrapper").height();
jQuery("#footer-wrapper").addClass("fixed-bottom");
jQuery("#footer-wrapper").hide();
if (windowHeight > content)
{
jQuery("#content").css("padding-bottom", jQuery("#footer-wrapper").height());
jQuery("#footer-wrapper").show();
}
}
关于javascript - 没有元素跳转的jQuery定位页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31157472/