JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<div class="slidershow middle">
<div class="slides">
<input type="radio" name="r" id="r1" checked>
<input type="radio" name="r" id="r2">
<input type="radio" name="r" id="r3">
<input type="radio" name="r" id="r4">
<input type="radio" name="r" id="r5">
<div class="slide s1">
<a href="#"> <img src="https://picsum.photos/id/1/700/600" alt=""></a>
</div>
<div class="slide">
<a href="#"><img src="https://picsum.photos/id/2/700/600" alt=""></a>
</div>
<div class="slide">
<a href="#"><img src="https://picsum.photos/id/3/700/600" alt=""></a>
</div>
<div class="slide">
<a href="#"><img src="https://picsum.photos/id/4/700/600" alt=""></a>
</div>
<div class="slide">
<a href="#"><img src="https://picsum.photos/id/5/700/600" alt=""></a>
</div>
</div>
<div class="navigation">
<label for="r1" class="bar active"></label>
<label for="r2" class="bar"></label>
<label for="r3" class="bar"></label>
<label for="r4" class="bar"></label>
<label for="r5" class="bar"></label>
</div>
</div>
CSS
*{ margin: 0px;
padding: 0px;}
.slidershow{
width: 100%;
height: 100%;
overflow: hidden;
position: absolute;
max-height: 70%;
}
.middle{
position: absolute;
}
.navigation{
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
display: flex;
}
.bar{
width: 60px;
height: 5px;
background-color: #c1c0c0;
margin: 6px;
cursor: pointer;
transition: 0.4s;
}
.bar:hover{
background: #ddcf19;
}
.bar.active{ background: #ddcf19; }
input[name="r"]{
position: absolute;
visibility: hidden;
}
.slides{
width: 500%;
height: 100%;
display: flex;
}
.slide{
width: 20%;
transition: 0.6s;
}
.slide a{
display: block;
width: 100%;
height: 100%;
cursor: pointer;
}
.slide img{
width: 100%;
height: 100%;
object-fit: cover;
}
#r1:checked ~ .s1{
margin-left: 0;
}
#r2:checked ~ .s1{
margin-left: -20%;
}
#r3:checked ~ .s1{
margin-left: -40%;
}
#r4:checked ~ .s1{
margin-left: -60%;
}
#r5:checked ~ .s1{
margin-left: -80%;
}
JavaScript
$(document).on('click', 'label', function() {
$(this).addClass('active').siblings().removeClass('active');
});
var slideshowInterval = null;
function startSlideshow() {
slideshowInterval = setInterval(function () {
var next = $('.active').next('.bar');
if (!next.length) {
next = $('.bar:eq(0)');
}
next.click();
}, 2000);
}
function stopSlideshow() {
clearInterval(slideshowInterval);
}
startSlideshow();
$('.slides')
.on('mouseover', stopSlideshow)
.on('mouseleave', startSlideshow);