如何获得scrollToFix插件限制以停止在我的网站的页脚? [英] How do I get the scrollToFix plugin limit to stop at my website's footer?

查看:76
本文介绍了如何获得scrollToFix插件限制以停止在我的网站的页脚?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网站上使用 scrollToFix 脚本来修复广告,因为用户向下滚动了页面以及在用户到达页脚时释放(以使广告不会与页脚重叠).但是,下面的代码使广告停止在页面的第三到一半之间滚动,而不是在页面尾部滚动.将其设置为滚动到容器的externalHeight减去页脚的高度,也会使其停在该位置.

I am using the scrollToFix script on my website to fix the ads as the user scrolls down the page as well as release when the user reaches the footer (so that the ads do not overlap the footer). My code below, however, causes the ads to stop scrolling between a third and half way down the page, rather than at the footer. Setting it to scroll to the outerHeight of the container minus the height of the footer leaves it stopping at that spot as well.

$(document).ready(function() {
     $('.right').scrollToFixed({
          marginTop: $('.float').outerHeight() + 8, 
          limit: $('footer').offset().top 
     });
});

关于如何使其更准确地停止运转,是否有任何想法?

Are there any ideas on how to get it to stop more accurately?

推荐答案

这可能是因为在您准备好文档后,您的网站会更改字体的高度,这是因为字体&图片等.尝试将事件绑定到窗口load事件.

It's probably because your site changes height after the document is ready, due to fonts & images etc. Try binding the event to the window load event.

$(function() {
    $('window').on('load', function() {
        $('.right').scrollToFixed({
            marginTop: $('.float').outerHeight() + 8, 
            limit: $('footer').offset().top 
        });
    });
});

这篇关于如何获得scrollToFix插件限制以停止在我的网站的页脚?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆