JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<nav class="menu">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
CSS
nav ul {
display: flex;
margin: 0;
padding: 0;
}
nav ul li {
list-style: none;
margin: 0;
padding: 0;
flex: 1;
display: flex;
}
nav ul li a {
display: block;
height: 70px;
line-height: 70px;
text-align: center;
text-decoration: none;
flex: 1;
background: white;
color: blue;
font-size: 1.5em;
position: relative;
}
nav ul li a:after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 0%;
transition-property: height;
transition-duration: .3s;
background: white;
mix-blend-mode: difference;
}
nav ul li a:hover:after,
nav ul li.active a:after {
height: 100%;
}
JavaScript
$(document).ready(function() {
$('.menu ul li').on('click', 'a', function() {
$(this).parent().siblings('li.active').removeClass('active');
$(this).parent().addClass('active');
});
});