在firefox和互联网探险家与jquery固定标题的bug [英] bug in firefox and internet explorer with jquery fixed header

查看:189
本文介绍了在firefox和互联网探险家与jquery固定标题的bug的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,其他开发者,

我一直在做一个固定的标题,在顶部固定的标题滚动到位。

I have been working on a fixed header that snaps into place with a top fixed header on scroll.

它适用于chrome,但不工作在interent explorer或firefox。

it works on chrome, but doesnt work on interent explorer or firefox.

任何帮助将是巨大的。

Any help would be great.

http://jsfiddle.net/j08691 / f95sW / 4 /

var offset = $(".sticky-header").offset();
var sticky = document.getElementById("sticky-header")
var additionalPixels = 50;

$(window).scroll(function () {
    if ($('body').scrollTop() > offset.top - additionalPixels) {
        $('.sticky-header').addClass('fixed');
    } else {
        $('.sticky-header').removeClass('fixed');
    }
}); 


推荐答案

问题是 $ 'body')。scrollTop()

code> $(document).scrollTop()

http://jsfiddle.net/f95sW/11/rel =nofollow>演示

Here is a demo

这篇关于在firefox和互联网探险家与jquery固定标题的bug的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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