JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://github.com/less/less.js/blob/master/dist/less.min.js"></script>
<ol class="slideshow">
<li> <span>Image 01</span>
</li>
<li> <span>Image 02</span>
</li>
<li> <span>Image 03</span>
</li>
<li> <span>Image 04</span>
</li>
<li> <span>Image 05</span>
</li>
<li> <span>Image 06</span>
</li>
</ol>
CSS
.slideshow {
position: absolute;
width: 100%;
height: 100%;
top: 0px;
left: 0px;
z-index: 0;
}
.slideshow li span {
width: 100%;
height: 100%;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
background-size: cover;
background-position: 50% 50%;
background-repeat: none;
opacity: 0;
z-index: 0;
animation: imageAnimation 24s linear infinite 0s;
}
.slideshow li:nth-child(1) span {
background-image: url(https://unsplash.it/700/400?image=24)
}
.slideshow li:nth-child(2) span {
background-image: url(https://unsplash.it/700/700?image=42);
animation-delay: 4s;
}
.slideshow li:nth-child(3) span {
background-image: url(https://unsplash.it/700/400?image=64);
animation-delay: 8s;
}
.slideshow li:nth-child(4) span {
background-image: url(https://unsplash.it/700/400?image=52);
animation-delay: 12s;
}
.slideshow li:nth-child(5) span {
background-image: url(https://unsplash.it/700/400?image=84);
animation-delay: 16s;
}
.slideshow li:nth-child(6) span {
background-image: url(https://unsplash.it/700/400?image=62);
animation-delay: 20s;
}
@keyframes imageAnimation {
0% {
opacity: 0;
animation-timing-function: ease-in;
}
3% {
opacity: 1;
animation-timing-function: ease-out;
}
23% {
opacity: 1
}
26% {
opacity: 0
}
100% {
opacity: 0
}
}
/* Demo Purposes */
html, body {
margin: 0;
padding: 0;
}
ol {
margin: 0;
padding: 0;
list-style: none;
}
JavaScript
$.fn.randomize = function(selector){
var $elems = selector ? $(this).find(selector) : $(this).children(),
$parents = $elems.parent();
$parents.each(function(){
$(this).children(selector).sort(function(){
return Math.round(Math.random()) - 0.5;
}).detach().appendTo(this);
});
return this;
};
$('ol.slideshow').randomize();