JSFiddle - React, Tailwind, and code Playground
HTML
<span>
<a href="#div1">Div 1</a>
<a href="#div2">Div 2</a>
<a href="#div3">Div 3</a>
<a href="#div4">Div 4</a>
<a href="#div5">Div 5</a>
</span>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<div id="div4"></div>
<div id="div5"></div>
CSS
html, body {height:100%;margin:0;}
span {position:fixed;width:100%;text-align:center;background:#fff;}
a {display:inline-block;vertical-align:top;margin:0 30px;text-decoration:none;font:700 .95em/40px sans-serif;color:#262626;transition:all .4s ease;}
a:hover {color:#09f;}
div {height:100%;background:#A30029;}
div+div {background:#235F76;}
div+div+div {background:#489660;}
div+div+div+div {background:#7A7971;}
div+div+div+div+div {background:#6A771F;}
JavaScript
window.requestAnimationFrame || (window.requestAnimationFrame = window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function (a) {
window.setTimeout(a, 1E3 / 60)
});
function addEvent(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d||!1):a.attachEvent('on'+b,c);}
function goTo(e){
function doScroll(){
var progress = (new Date - start) / duration;
if (progress > 1) progress = 1;
var delta = (progress < .5) ? Math.pow(2 * progress, 3) / 2 : (2 - Math.pow(2 * (1 - progress), 3)) / 2,
result = (targetTop - from) * delta + from;
window.scrollTo(0, result)
if (progress === 1) return;
window.requestAnimationFrame(doScroll);
}
(e.preventDefault) ? e.preventDefault() : (e.returnValue = false);
var target = (e.target || e.srcElement).hash.substring(1),
targetTop = document.getElementById(target).offsetTop,
from = window.pageYOffset || document.documentElement.scrollTop,
start = new Date;
doScroll();
}
var link = document.querySelectorAll("span a"),
duration = 1000,
i = 0,
l = link.length;
for(; i<l; i++) addEvent(link[i], "click", goTo, false);