JSFiddle - React, Tailwind, and code Playground
by Milan Karagunović
HTML
<nav>
<ul>
<li data-rel="div1">DIV 1</li>
<li data-rel="div2">DIV 2</li>
<li data-rel="div3">DIV 3</li>
</ul>
</nav>
<div id="wrapper">
<div id="div1">
</div>
<div id="div2">
</div>
<div id="div3">
</div>
</div>
CSS
body {
background: #eee;
min-height: 100%;
}
nav {
background: #666;
display: block;
height: 50px;
margin-bottom: 50px;
text-align: center;
border-bottom: 1px solid #fff;
}
ul {
list-style: none;
}
ul li {
background: #333;
display: inline-block;
margin: 0 10px;
padding: 15px 50px;
height: 20px;
font-family: Verdana;
letter-spacing: 1px;
color: #fff;
cursor: pointer;
transition: all 0.2s ease-in;
}
ul li:hover {
background: #0296cc;
color: #333;
}
div {
background: #999;
width: 500px;
height: 500px;
margin: 0 auto 10px;
}
JavaScript
$(function() {
$('nav ul li').click(function() {
$('html, body').animate({ scrollTop: $('#'+$(this).data('rel')).offset().top }, 900);
});
});