Scroll hash offset with CSS & jQuery

0 votes
added Apr 17, 2019 in Plugins by LC Marshal Captain (25,790 points)

<!--anchor area-->
<div class="hash-offset" id="titleanchor"></div>
<h3>Title goes here</h3>

<div class="floating-bar">
  <a href="#titleanchor"><div class="floating-menu">link to title</div></a>


.hash-offset {
  display: block;
  position: relative;
  top: -70px;
  visibility: hidden;


$(".floating-bar a[href^='#']").click(function(e) {
  var position = $($(this).attr("href")).offset().top;

  $("body, html").animate({
    scrollTop: position
  } /* speed */ );
}); - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.