JSFiddle - React, Tailwind, and code Playground
by Matteo Melillo
HTML
<section class="nivo-slider">
<div class="navi"></div>
<a class="prev" href="javascript:void(0);">«</a>
<a class="next" href="javascript:void(0);">»</a>
<div id="nivo">
<div class="element slide1"></div>
<div class="element slide2"></div>
<div class="element slide3"></div>
<div class="element slide4"></div>
<div class="element slide5"></div>
</div>
</section>
CSS
.navi{ position:absolute; top:auto; bottom:-20px; z-index:300; right:0; }
.navi a{
display:block;
background:#000;
-webkit-border-radius:10px;
-moz-border-radius:10px;
-ms-border-radius:10px;
-o-border-radius:10px;
border-radius:10px;
border:none;
width:11px;
height:11px;
text-indent:-999em;
overflow:hidden;
margin:8px 5px 0 0;
cursor:pointer;
float:left;
}
.navi a.active, .navi a:hover{ background-color:red; }
.nivo-slider{
position:relative;
margin: 30px auto 0;
width:620px;
height: 460px;
}
#nivo{
position: relative;
overflow: hidden;
width: 620px;
height: 460px;
}
#nivo .element {
opacity: 0;
filter: alpha(opacity = 0);
display: block;
position: absolute;
top: 0;
left: 0;
width: 640px;
height: 460px;
zoom: 1;
}
.prev{
position: absolute;
top: 185px;
left: -40px;
cursor: pointer;
color:#000;
font-size:50px;
line-height:normal;
text-decoration:none;
}
.next{
position: absolute;
top: 185px;
line-height:normal;
right: -40px;
cursor: pointer;
color:#000;
font-size:50px;
text-decoration:none;
}
#nivo .slide1 {
background-image: #4e4e48;
background-image: -webkit-linear-gradient(bottom right, #de55d7 0%, #0d9602 100%, #000000 100%);
background-image: -moz-linear-gradient(bottom right, #de55d7 0%, #0d9602 100%, #000000 100%);
background-image: -o-linear-gradient(bottom right, #de55d7 0%, #0d9602 100%, #000000 100%);
background-image: -ms-linear-gradient(bottom right, #de55d7 0%, #0d9602 100%, #000000 100%);
background-image: linear-gradient(bottom right, #de55d7 0%, #0d9602 100%, #000000 100%);
}
#nivo .slide2 {
background-image: #6a7259;
background-image: -webkit-linear-gradient(top left, #eb622d 0%, #52f5df 100%, #000000 100%);
background-image: -moz-linear-gradient(top left, #eb622d 0%, #52f5df 100%, #000000 100%);
background-image:...
JavaScript
jQuery(document).ready(function($) {
var nEle = $('#nivo .element').size(),
i = 1,
counter = 1,
squareT = 0,
move = false,
fading = function() {
if (move) { return false; }
move = true;
$('#nivo').find('.element:nth-child(' + counter + ')').animate({
opacity:'0'
}, 800);
$('.nivo-slider .navi').find('a:nth-child(' + counter + ')').removeClass('active');
if ( counter == nEle ) {
counter = 0;
};
$('.nivo-slider .navi').find('a:nth-child(' + ( counter + 1 ) + ')').addClass('active');
$('#nivo').find('.element:nth-child(' + ( counter + 1 ) + ')').animate({
opacity:'1'
}, 800, function() {
move = false;
}
);
counter = counter + 1;
},
fadingReverse = function() {
if (move) { return false; }
move = true;
$('#nivo').find('.element:nth-child(' + counter + ')').animate({
opacity:'0'
}, 800);
$('.nivo-slider .navi').find('a:nth-child(' + counter + ')').removeClass('active');
if ( counter == 1 ) {
counter = nEle+1;
};
$('.nivo-slider .navi').find('a:nth-child(' + ( counter - 1 ) + ')').addClass('active');
$('#nivo').find('.element:nth-child(' + ( counter - 1 ) + ')').animate({
opacity:'1'
}, 800, function() {
move = false;
}
);
counter = counter-1;
},
fadingSquares = function() {
if (move) { return false; }
move = true;
$('#nivo').find('.element:nth-child(' + counter + ')').animate({
opacity:'0'
}, 800);
$('.nivo-slider .navi').find('a:nth-child('...