0

I have a website with a fixed menu, and the menu links throw the user down the one page to the content for the link they clicked. But because I have the fixed menu, when I click on a link in the menu and the website throws me down, it would be perfect, if my menu wasn't in the way. But it is. I'd like the content to start after my fixed menu, but I don't know how to get that done. This is the jQuery I use to get the links to throw the user down:

$(document).ready(function(){
$('li a[href^="#"]').on('click',function (e) {
    e.preventDefault();

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

$('html, body').stop().animate({
     'scrollTop': $target.offset().top
}, 900, 'swing');
            window.location.hash = target;
        });
    });
});
4

1 回答 1

0

更改$target.offset().top$target.offset().top - 64考虑固定菜单的高度。根据菜单高度按需调整,或者直接在代码中查询菜单当前实际高度。

于 2015-04-29T07:50:30.987 回答