jquery - Add Margin on Smooth Scroll -


i adding smoothscrolling one-page freelance site. whenever scrolls page shows 60px top of section bc of fix-top nav scroll looking when scrolls down

this

when i'd push 60px down , scroll down instead.

enter image description here

i pulled scroll code w3 bc solution seems simplest. starting use jquery more appreciate. code used below:

    <script>   $(document).ready(function(){     $(".navbar a, footer a[href='#mypage']").on('click', function(event) {      if (this.hash !== "") {        event.preventdefault();        var hash = this.hash;        $('html, body').animate({         scrolltop: $(hash).offset().top       }, 1100, function(){          window.location.hash = hash;         });       } // end if     });   }) </script> 

i fix myself add - 60 after top$(hash).offset().top

changed section if else ever has issue:

('html, body').animate({ scrolltop: $(hash).offset().top - 60 }, 1100, function(){ 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -