0

我在我的网站上使用锚导航和固定标题。通过单击我的菜单的链接,页面滚动到链接的#。我添加了一个 JS 代码来计算我的标题的高度并将高度添加到我的 # 链接,因此该部分不会显示在我的固定标题下。它在 chrome 上运行良好,但在 firefox 上运行良好,我不明白我做错了什么,有人可以帮我解决这个问题吗?这是js代码:

function scrolling(){
    $('a[href^="#"]').bind('click.smoothscroll',function (e) {
        e.preventDefault();

        var target = this.hash,
        $target = $(target);

        var offset  = $('#header').outerHeight(true);
        //alert(offset);

        $('html, body').stop().animate({
            'scrollTop': $target.offset().top-offset
            //--OFFSET--//
        }, 1000, 'swing', function () {
            window.location.hash = target;
        });
    });
}

和CSS:

#header{position: fixed;z-index: 1000;top: 0;padding-left:25px;padding-top: 20px;height: 75px;width:100%;min-width:590px}

非常感谢你的帮助

4

0 回答 0