Created
December 10, 2014 13:32
-
-
Save anderser/ad4f77a799dceabdb126 to your computer and use it in GitHub Desktop.
Stacked
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.stack { | |
margin: 20px auto; | |
width: 400px; | |
padding: 0; | |
position: relative; | |
max-width: 100%; | |
} | |
.stack div { | |
max-width: 100%; | |
position: absolute; | |
top: 0; | |
left: 0; | |
-webkit-transition: all 0.3s; | |
transition: all 0.3s; | |
outline: 1px solid transparent; | |
width: 300px; | |
height: 300px; | |
} | |
.stack div:last-child { | |
position: relative; | |
} | |
/* Queue */ | |
.stack-queue { | |
-webkit-transition: all 0.3s; | |
transition: all 0.3s; | |
} | |
.stack-queue.active { | |
-webkit-transform: scale(0.9); | |
transform: scale(0.9); | |
} | |
.stack-queue div { | |
-webkit-backface-visibility: hidden; | |
backface-visibility: hidden; | |
-webkit-transform-origin: 50% -50%; | |
transform-origin: 50% -50%; | |
} | |
.stack-queue.active div { | |
-webkit-transform: scale(.7); | |
transform: scale(.7); | |
} | |
.stack-queue.active div:nth-last-child(2) { | |
-webkit-transform: scale(.8); | |
transform: scale(.8); | |
} | |
.stack-queue.active div:nth-last-child(1) { | |
-webkit-transform: scale(.9); | |
transform: scale(.9); | |
} | |
.stack-queue.active div.removed { | |
-webkit-transition: all 1s; | |
transition: all 1s; | |
-webkit-transform: scale(11); | |
transform: scale(11); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" class="no-js"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<title>Simple Stack Effects</title> | |
<meta name="description" content="Simple Stack Effects" /> | |
<meta name="keywords" content="stack, effect, 3d, rotate, hover, creative, inspiration, web design" /> | |
<meta name="author" content="Codrops" /> | |
<link rel="shortcut icon" href="../favicon.ico"> | |
<link rel="stylesheet" type="text/css" href="css/normalize.css" /> | |
<link rel="stylesheet" type="text/css" href="css/demo.css" /> | |
<link rel="stylesheet" type="text/css" href="css/component.css" /> | |
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> | |
<!--[if IE]> | |
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> | |
<![endif]--> | |
</head> | |
<body> | |
<div class="container"> | |
<section> | |
<figure class="stack stack-queue active"> | |
<div style="background-color: blue;" class="card" id="card0"></div> | |
<div style="background-color: black;" class="card" id="card1"></div> | |
<div style="background-color: red;" class="card" id="card2"></div> | |
<div style="background-color: yellow;" class="card" id="card3"></div> | |
<div style="background-color: blue;" class="card" id="card4"></div> | |
<div style="background-color: green;" class="card" id="card5"></div> | |
<div style="background-color: red;" class="card" id="card6"></div> | |
<div style="background-color: yellow;" class="card" id="card7"></div> | |
<div style="background-color: black;" class="card" id="card8"></div> | |
<div style="background-color: coral;" class="card" id="card9"></div> | |
<div style="background-color: cyan;" class="card" id="card10"></div> | |
<div style="background-color: magenta;" class="card" id="card11"></div> | |
<div style="background-color: moccasin;" class="card" id="card12"></div> | |
</figure> | |
</section> | |
</div><!-- /container --> | |
<script src="js/main.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
var scaleout = 0.7; | |
var currentcard = +$('.card:last-child').attr('id').replace("card", ""); | |
console.log(currentcard); | |
$('.stack').on('click', function(ev) { | |
$currentcard = $(this).find('#card'+currentcard).not('removed'); | |
$currentcard.css({ | |
'-webkit-transform' : 'scale(' + 11 + ')', | |
'-moz-transform' : 'scale(' + 11 + ')', | |
'-ms-transform' : 'scale(' + 11 + ')', | |
'-o-transform' : 'scale(' + 11 + ')', | |
'transform' : 'scale(' + 11 + ')' | |
}); | |
$currentcard.addClass("removed"); | |
scaleout = 0.7; | |
var element = 0; | |
$.each([currentcard-4, currentcard-3, currentcard-2, currentcard-1], function(index, value) { | |
$("#card"+value).not("removed").css({ | |
'-webkit-transform' : 'scale(' + scaleout + ')', | |
'-moz-transform' : 'scale(' + scaleout + ')', | |
'-ms-transform' : 'scale(' + scaleout + ')', | |
'-o-transform' : 'scale(' + scaleout + ')', | |
'transform' : 'scale(' + scaleout + ')' | |
}); | |
scaleout = scaleout + .1; | |
}); | |
currentcard = currentcard - 1; | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment