<div class='title' id='about'>About Us</div>
<a class='mm' href='about.php#about'>About Us</a>
I have a sticky positioned element above the target div so the .title
div is not visible after loading the page
How can I scroll up the document after loading, for example for 54px, so the target div comes into view?
I tried this, without success:
$(window).on('load', function(){
if(!window.location.hash == ''){
window.scrollBy({top: 54, behavior: 'auto'});
}
});
2
Answers
If a sticky header gets in the way of the scrolled-to Target element, use in CSS:
given your sticky page nav or header occupies that
54px
height.on page reload, cant you just re-direct page to
href=about.php#about