JSFiddle - React, Tailwind, and code Playground
by FrelCee
HTML
<div id = 'container' >
<div id = 'first'> First </div>
<div id = 'second'> Second </div>
<div id = 'third'> Third </div>
</div>
CSS
#first {
width: 70px;
height: 20px;
background: #ff0;
}
#second{
width: 70px;
height: 20px;
background: #0f0;
}
#third{
width: 70px;
height: 20px;
background: #f00;
}
#container{
width:90px;
height:auto;
background:#999;
overflow:hidden;
}
div {
margin-top:10px;
margin-bottom:10px;
position:relative;
}
JavaScript
// Hide #first, #second, #third on document ready
$(document).ready(function(){
$('#first,#second,#third').css("left", "-100px");
});
// On hover function
var hover = $('#container');
$(hover).hover(function(){
$(this).find('#first').stop().animate({left:10}, 600);
$(this).find('#second').delay(100).stop().animate({left:10}, 600);
$(this).find('#third').delay(250).stop().animate({left:10}, 600);
}, function() {
$(this).find('#first').stop().animate({left:-100}, 600);
$(this).find('#second').delay(100).stop().animate({left:-100}, 600);
$(this).find('#third').delay(250).stop().animate({left:-100}, 600);
}); // on mouse out hide divs