JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-1.12.1.min.js"></script>
<a href="#home">Home</a>
<a href="#about">About</a>
<div class="Home-section" id="home"><h1> Hello </h1>
</div>
<div class="About-section" id="about"><h1>Bye</h1>
</div>
CSS
.Home-section {
height: 500px;
background:url('http://lorempicsum.com/futurama/627/300/4');
background-size: cover;
background-attachment: fixed;
}
.About-section {
height: 300px;
background: url('http://lorempicsum.com/futurama/627/200/3') no-repeat;
background-size: cover;
background-attachment: fixed;
}
JavaScript
$(document).on('click', 'a[href^="#"]', function(e) {
// target element id
var id = $(this).attr('href');
// target element
var $id = $(id);
if ($id.length === 0) {
return;
}
// prevent standard hash navigation (avoid blinking in IE)
e.preventDefault();
// top position relative to the document
var pos = $(id).offset().top;
// animated top scrolling
$('body, html').animate({scrollTop: pos});
});