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
when i'd push 60px down , scroll down instead.
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
Post a Comment