JSFiddle - React, Tailwind, and code Playground
HTML
<div id="cssmenu">
<ul id="list">
<li><a href="#home">Home</a></li>
<li><a style="display:none" href="#home2"></a></li>
<li><a href="#newsletter">Newsletter</a></li>
<li><a href="#directions">Directions</a></li>
<li><a href="#directions2">Directions2</a></li>
<li><a href="#contact">Contact us</a></li>
<li><a href="#actor">actor</a></li>
<li><a style="display:none" href="#actor2"></a></li>
<li><a style="display:none" href="#actor3"></a></li>
<li><a href="#market">market</a></li>
<li><a style="display:none" href="#market2"></a></li>
<li><a style="display:none" href="#market3"></a></li>
<li><a href="#calendar">calendar</a></li>
</ul>
<button id="prev">Previous</button>
<button id="next">Next</button>
</div>
<div id="wrap">
<div id="home" class="panel">
<h2>Home</h2>
</div>
<div id="home2" class="panel">
<h2>We are still in Home item</h2>
</div>
<div id="newsletter" class="panel">
<h2>Newsletter</h2>
</div>
<div id="directions" class="panel">
<h2>Directions</h2>
</div>
<div id="directions2" class="panel">
<h2>Directions2</h2>
</div>
<div id="contact" class="panel">
<h2>Contact</h2>
</div>
<div id="actor" class="panel">
<h2>actor</h2>
</div>
<div id="actor2" class="panel">
<h2>we are still in actor</h2>
</div>
<div id="actor3" class="panel">
<h2>we are still in actor</h2>
</div>
<div id="market" class="panel">
<h2>market</h2>
</div>
<div id="market2" class="panel">
<h2>we are still in market</h2>
</div>
<div id="market3" class="panel">
<h2>we are still in market</h2>
</div>
<div id="calendar" class="panel">
<h2>we are in calendar</h2>
</div>
</div>
CSS
body {
margin: 0;
}
body, #wrap, .panel {
height: 100%;
overflow: hidden;
position: relative;
}
.panel {
width: 100%;
display: table;
background: #eee;
}
#wrap {
width: 1300%; /* 100 multiplied by the number of sections ( 13 ) */
margin: 0 auto;
margin-top: 60px;
float: left;
}
#wrap > div {
width: 8%; /* 100 divided by the number of sections ( 13 ) */
float: left;
}
#cssmenu ul {
margin: 0;
padding: 0;
font-size: 12px;
font-weight: bold;
background: #f2f1f2;
font-family: Arial, Helvetica, sans-serif;
border-bottom: 1px solid #f2f1f2;
zoom: 1;
}
#cssmenu ul:before {
content: '';
display: block;
}
#cssmenu ul:after {
content: '';
display: table;
clear: both;
}
#cssmenu li {
float: left;
margin: 0 auto;
padding: 0 4px;
list-style: none;
}
#cssmenu li a {
display: block;
float: left;
color: #797978;
text-decoration: none;
font-weight: bold;
padding: 10px 20px 7px 20px;
border-bottom: 3px solid transparent;
}
#cssmenu li a:hover {
color: #6c8cb5;
border-bottom: 3px solid #00b8fd;
}
#cssmenu li.active a {
display: inline;
border-bottom: 3px solid #00b8fd;
float: left;
margin: 0;
}
#cssmenu {
width: 100%;
position: fixed;
}
JavaScript
$(function() {
var content = '#cssmenu #list';
var section = content + ' > li';
function ghostCarousel() {
var v = $(window).width();
var w = $(section).width();
var c = (w * $(section).length - v) / 2;
$(content).width(w * $(section).length);
$(content).css('margin-left', -c);
$('#gcNav a.left').click(function(e) {
e.preventDefault();
if ($(content).is(':animated')) return false;
$(content).animate({ marginLeft: '-=' +w }, 1000, function() {
var first = $(section).eq(0);
$(section).eq(0).remove();
$(this).animate({ marginLeft: '+=' +w }, 0);
$(this).append(first);
});
});
$('#gcNav a.right').click(function(e) {
e.preventDefault();
if ($(content).is(':animated')) return false;
$(content).animate({ marginLeft: '+=' +w }, 1000, function() {
var end = $(section).length - 1;
var last = $(section).eq(end);
$(section).eq(end).remove();
$(this).animate({ marginLeft: '-=' +w }, 0);
$(this).prepend(last);
});
});
}
ghostCarousel();
$(window).resize(function() {
var v = $(window).width();
var w = $(section).width();
var c = (w * $(section).length - v) / 2;
$(content).css('margin-left', -c);
});
});