简体   繁体   中英

Jump to specific place on same page

Im trying "page jump" on same page to specific place.

Im trying simple solution with "id":

<a href="#apple">More about apples!</a>

<a name="apple"></a>

But I have on my page sticky header, and jumped text is showing under header, so that's really useless. When I use javascript with:

window.scrollBy(x, y);

its useless to, because when I reduce window, javascript jump on different place on page.

Any advices please? Thanks!

Add the offset according to height of your header

jQuery(document).ready(function(){
function secOffset(){
                        jQuery('html, body').animate({
                        scrollTop: jQuery(window.location.hash).offset().top + 60
                }, 0);
        }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM