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">content 2</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;
}
.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(){
// $(window).scrollTop(300);
$("ul li").on("click", function(e){
var $this = $(this);
var index = $this.index();
var leftOffset = $(".container")
.find("div")
.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();
});