JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body>
<style>
body {
overflow-x: hidden;
margin: 0;
padding: 0
}
#main-content {
position: absolute;
margin: 0;
padding: 0
}
ul {
margin: 0;
padding: 0;
list-style: none;
white-space: nowrap;
position: relative;
transition: all 0.4s ease;
left: -50vw;
}
ul li {
width: 25vw;
height: 100vh;
margin: 0;
padding: 0;
cursor: pointer;
display: inline-block;
}
.red {
background-color: red;
}
.blue {
background-color: blue;
}
.yellow {
background-color: yellow;
}
.green {
background-color: green;
}
.purple {
background-color: purple;
}
.gray {
background-color: gray;
}
</style>
<nav id="main-content">
<ul id="nav" style="left: 0">
<li class="red"></li>
<li class="blue"></li>
<li class="yellow"></li>
<li class="green"></li>
<li class="purple"></li>
<li class="gray"></li>
</ul>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script>
$(document).ready(function() {
console.log("OK");
});
</script>
</body>
</html>
JavaScript
const numberOfChild = $('ul').children().length;
const childWidth = $(this).width() / numberOfChild;
$('ul').on('mousemove', function(e) {
$(this).css('left', -1 * e.pageX + 'px')
});