JSFiddle - React, Tailwind, and code Playground
by Murat Kezli
HTML
<div id="slider">
<a href="#" class="control_next"></a>
<a href="#" class="control_prev"></a>
<div class="imageslide">
<img src="https://livedemo00.template-help.com/wt_48443/images/slide-1.jpg?1541455586939" data-thumb="demo/images/toystory.jpg" alt="" /> <a href="http://dev7studios.com">
<img src="https://livedemo00.template-help.com/wt_48443/images/slide-2.jpg?1541455586939" data-thumb="demo/images/up.jpg" alt="" title="This is an example of a caption" /></a>
<img src="https://livedemo00.template-help.com/wt_48443/images/slide-3.jpg?1541455586939" data-thumb="demo/images/walle.jpg" alt="" data-transition="slideInLeft" />
</div>
<div>
CSS
@import url(https://fonts.googleapis.com/css?family=Open+Sans:400,300,600);
html, body {
margin: 0;
padding: 0;
font-family: 'Open Sans';
}
#slider {
position: relative;
overflow: hidden;
margin: 0px auto 0 auto;
border-radius: 4px;
width:100%;
}
.imageslide {
position: relative;
margin: 0;
padding: 0;
}
.imageslide img {
position: relative;
display: block;
float: left;
margin: 0;
padding: 0;
width:100%;
height:auto;
background: #ccc;
text-align: center;
}
a.control_prev, a.control_next {
position: absolute;
top: 40%;
z-index: 999;
display: block;
padding: 4% 3%;
width: auto;
height: auto;
background: #2a2a2a;
color: #fff;
text-decoration: none;
font-weight: 600;
font-size: 18px;
opacity: 0.1;
cursor: pointer;
}
a.control_prev:hover, a.control_next:hover {
opacity: 1;
-webkit-transition: all 0.2s ease;
}
a.control_prev {
border-radius: 0 8px 8px 0;
}
a.control_next {
right: 0;
border-radius: 8px 0 0 8px;
}
JavaScript
jQuery(document).ready(function ($) {
setInterval(function () {
moveRight();
}, 5000);
var img
var slideCount = $('.imageslide img').length;
var slideWidth = $('.imageslide img').width();
var slideHeight = $('.imageslide img').height();
var sliderUlWidth = slideCount * slideWidth;
var slideyukseklik = $('#slider .imageslide img:last-child').height();
$('#slider').css({ width: slideWidth, height: slideyukseklik });
$('#slider').css({ width: sliderUlWidth, marginLeft: - slideWidth });
function moveLeft() {
$('#slider .imageslide').animate({
left: + slideWidth
}, 600, function () {
$('#slider .imageslide img:last-child').prependTo('#slider .imageslide');
$('#slider .imageslide').css('left', '');
});
}
function moveRight() {
$('#slider .imageslide ').animate({
left: - slideWidth
}, 600, function () {
$('#slider .imageslide img:first-child').appendTo('#slider .imageslide');
$('#slider .imageslide').css('left', '');
});
}
$('a.control_prev').click(function () {
moveLeft();
});
$('a.control_next').click(function () {
moveRight();
});
});