simple z shuffle
by mrjordy
HTML
<div class = "deck">
<div class="block block1" id="first">1</div>
<div class="block block2" id="second">2</div>
<div class="block block3" id="third">3</div>
<div class="block block4" id="fourth">4</div>
</div>
CSS
.deck {
margin: 30px 0 0 30px;
}
.block {
width: 80px;
height: 80px;
border: 1px solid rgba(255,255,255,.3);
background: #92c4d5;
position: absolute;
text-align: center;
line-height: 80px;
color: blue;
font-family: kalinga;
z-index: auto;
cursor: pointer;
opacity: .95;
border-bottom-left-radius: 30px;
border-top-right-radius: 30px;
transition: .2s;
}
.block:hover {
border: darkblue 1px solid;
}
.block1 {
margin: 0 0 0 0;
}
.block2 {
margin: 0 0 0 60px;
}
.block3 {
margin: 0 0 0 120px;
}
.block4 {
margin: 0 0 0 180px;
}
.shuffleFirst {
z-index: 40;
background: lightblue;
border: 1px solid white;
color: black;
cursor: auto;
height: 100px;
width: 100px;
line-height: 100px;
border-radius: 0;
}
.shuffleFirst:hover {
border: 1px solid white;
}
.block1.shuffleFirst {
margin: 0 0 0 -10px;
}
.block2.shuffleFirst {
margin: 0 0 0 50px;
}
.block3.shuffleFirst {
margin: 0 0 0 110px;
}
.block4.shuffleFirst {
margin: 0 0 0 170px;
}
.shuffleSecond {
z-index: 30;
background: #92c4d5;
}
.shuffleThird {
z-index: 20;
background: #70a9bc;
}
.shuffleFourth {
z-index: 10;
background: #417a8d;
}
JavaScript
$('#first').click(function() {
$('#first').addClass('shuffleFirst').removeClass('shuffleSecond shuffleThird shuffleFourth');
$('#second').removeClass('shuffleFirst shuffleThird shuffleFourth').addClass('shuffleSecond');
$('#third').removeClass('shuffleFirst shuffleSecond shuffleFourth').addClass('shuffleThird');
$('#fourth').removeClass('shuffleFirst shuffleSecond shuffleThird').addClass('shuffleFourth');
});
$('#second').click(function() {
$('#second').addClass('shuffleFirst').removeClass('shuffleSecond shuffleThird shuffleFourth');
$('#first, #third').removeClass('shuffleFirst shuffleThird shuffleFourth').addClass('shuffleSecond');
$('#fourth').removeClass('shuffleFirst shuffleSecond shuffleFourth').addClass('shuffleThird');
});
$('#third').click(function() {
$('#third').addClass('shuffleFirst').removeClass('shuffleSecond shuffleThird shuffleFourth');
$('#second, #fourth').removeClass('shuffleFirst shuffleThird shuffleFourth').addClass('shuffleSecond');
$('#first').removeClass('shuffleFirst shuffleSecond shuffleFourth').addClass('shuffleThird');
});
$('#fourth').click(function() {
$('#fourth').addClass('shuffleFirst').removeClass('shuffleSecond shuffleThird shuffleFourth');
$('#third').removeClass('shuffleFirst shuffleThird shuffleFourth').addClass('shuffleSecond');
$('#second').removeClass('shuffleFirst shuffleSecond shuffleFourth').addClass('shuffleThird');
$('#first').removeClass('shuffleFirst shuffleSecond shuffleThird').addClass('shuffleFourth');
});