JSFiddle - React, Tailwind, and code Playground
HTML
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<body>
<div id="featured">
<ul class="tabs">
<li>Condo One</li>
<li>Condo Two</li>
<li>Condo Three</li>
<li>Condo Four</li>
<li>Condo Five</li>
</ul>
<div class="container">
<img src="https://raw.githubusercontent.com/michaelsoriano/image-rotator/master/images/image1.jpg" />
</div>
<div class="container">
<img src="https://raw.githubusercontent.com/michaelsoriano/image-rotator/master/images/image2.jpg" />
</div>
<div class="container">
<img src="https://raw.githubusercontent.com/michaelsoriano/image-rotator/master/images/image3.jpg" />
</div>
<div class="container">
<img src="https://raw.githubusercontent.com/michaelsoriano/image-rotator/master/images/image4.jpg" />
</div>
<div class="container">
<img src="https://raw.githubusercontent.com/michaelsoriano/image-rotator/master/images/image5.jpg" />
</div>
</div>
</body>
CSS
#featured {
width: 518px;
padding: 18px 120px 10px 21px;
background: #ebebeb !important;
position: relative;
border: 1px solid #ccc;
height: 434px;
background: #fff;
margin-bottom: 35px;
border-radius: 6px;
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
}
#featured ul.tabs {
position: absolute;
top: 18px;
left: 538px;
padding: 0;
margin: 0;
}
#featured ul.tabs li {
font-size: 10px;
color: #666;
line-height: 10px;
height: 75px;
color: #333;
overflow: hidden;
width: 96px;
background: #fff;
margin-bottom: 11px;
position: relative;
}
#featured ul.tabs li a.title {
position: absolute;
z-index: 5;
color: #fff;
font-family: arial;
bottom: 7px;
width: 96px;
text-align: center;
text-shadow: 1px -1px 0 #000;
text-decoration: none;
}
#featured ul.tabs li img {
width: 96px;
height: 75px;
opacity: 0.5;
z-index: 3;
}
#featured ul.tabs li.current img,
#featured ul.tabs li img:hover {
opacity: 1.0;
}
#featured div.container img {
height: 420px;
width: 500px;
position: absolute;
}
#featured div.container img:hover {
cursor:wait;
}
#featured div.container {
position: relative;
z-index: 0;
}
#featured div.container.previous {
z-index: 1;
}
#featured div.container.current {
z-index: 2;
}
#featured h2 {
font-size: 40px;
font-family: Arial;
color: #fff;
padding: 5px 5px 5px 12px;
margin: 0;
overflow: hidden;
line-height: 65px;
text-transform: uppercase;
height: 50px;
overflow: hidden;
position: absolute;
top: 350px;
text-shadow: 1px -1px 0 #000;
text-align: center;
letter-spacing: -1px;
width: 475px;
}
JavaScript
$(document).ready(function(){
$('.container').each(function(e){
if(e == 0){
$(this).addClass('current');
}
$(this).attr('id', 'handle' + e);
})
$('.tabs li').each(function(e){
if(e == 0){
$(this).addClass('current'); //adds class current to 1st li
}
$(this).wrapInner('<a class="title"></a>'); //wraps list items in anchor tag
$(this).append('<a><img /></a>'); //creates img tag
$(this).children('a').attr('href', '#handle' + e);//adds href to the anchors
y = $('#handle' + e + ' img').attr('src'); //grabs src from large pix
$(this).find('img').attr('src', y); //appends src to small pix
t = $(this).children('a').text();
$('#handle' + e).append('<h2>' + t + '</h2>'); //adds h2 and text to big images
})
$('.tabs li a').click(function(){
c = $(this).attr('href');
if($(c).hasClass('current')){
return false;
}else{
showImage($(c), 20);
$('.tabs li').removeClass('current');
$(this).parent().addClass('current');
return false;
}
})
runRotateImages();
var theRotator;
$("#featured").hover(
function(){
clearTimeout(theRotator);
},
function(){
runRotateImages();
}
)
})
function showImage(img, duration){
$('.container').removeClass('current').css({
"opacity" : 0.0,
"zIndex" : 2
});
img.animate({opacity:1.0}, duration, function(){
$(this).addClass('current').css({zIndex:1});
});
}
function runRotateImages(){
function rotateImages(){
var curPhoto = $("div.current");
var nxtPhoto = curPhoto.next();
var curTab = $(".tabs li.current");
var nxtTab = curTab.next();
if (nxtPhoto.length == 0) {
nxtPhoto = $('#featured div:first');
nxtTab = $('.tabs li:first-child');
}
curTab.removeClass('current');
nxtTab.addClass('current');
showImage(nxtPhoto, 300);
}
theRotator = setInterval(rotateImages(), 4000);
}