JSFiddle - React, Tailwind, and code Playground
by lasha
HTML
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
<div class="container">
<div class="one">content 1</div>
<div class="two">
<div class="ipad">
<img class="active" src="http://placehold.it/350x150&text=1">
<img src="http://placehold.it/350x150&text=2">
<img src="http://placehold.it/350x150&text=3">
<img src="http://placehold.it/350x150&text=4">
<img src="http://placehold.it/350x150&text=5">
<img src="http://placehold.it/350x150&text=6">
<img src="http://placehold.it/350x150&text=7">
</div>
</div>
<div class="three">content 3</div>
</div>
CSS
body {
background: #CCC;
}
.container {
background: #505;
width: 3000px;
padding-top: 1px;
}
.one, .two, .three {
float: left;
height: 500px;
width: 500px;
border: 1px solid #000;
margin-top: 50px;
margin-right: 50px;
}
.two img {
position: absolute;
display: none;
}
.two img.active {
display: block;
}
.two .ipad {
margin: 20px;
}
.one {
background: #F00;
}
.two {
background: #0F0;
}
.three {
background: #00F;
}
ul {
position: fixed;
margin: 0 0 10px;
padding: 3px 5px;
top: 0;
left: 0;
background: #FFF;
width: 100%;
}
ul li {
display: inline-block;
margin-right: 20px;
}
JavaScript
$(function () {
var $images = $(".two img");
var imagesCount = $images.length;
$images.on("click", function (e) {
var $this = $(this);
var index = $this.index();
$this.removeClass("active");
if (index === imagesCount - 1) {
$images.eq(0).addClass("active");
} else {
$this.next().addClass("active");
}
});
// $(window).scrollTop(300);
$("ul li").on("click", function (e) {
var $this = $(this);
var index = $this.index();
var leftOffset = $(".container")
.children()
.eq(index)
.offset().left;
$("html,body").animate({
scrollLeft: leftOffset - 10
}, 300);
});
var $contentDivs = $(".one, .two, .three");
var $container = $(".container");
$(window).resize(function (e) {
var $this = $(this);
$contentDivs.width($this.width() - 20);
$container.width($this.width() * 3 + (32 * 3));
});
$(window).resize();
});