Short and sweet version:
Is it possible to combine position: relative and position: absolute with smooth CSS-transitions?
Verbose v
@nikc.org
Maybe you could use translate instead:
div.deck-container {
position: relative;
}
div.deck-container li {
background-color: #fff;
position: relative;
border: 1px solid black;
padding: 3px;
display: inline-block;
-webkit-transition: all 0.5s ease-in-out;
-moz-transition: all 0.5s ease-in-out;
-o-transition: all 0.5s ease-in-out;
-ms-transition: all 0.5s ease-in-out;
transition: all 0.5s ease-in-out;
}
div.deck-container.collapsed li:first-child {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
-o-transform: translate(0, 0);
transform: translate(0, 0);
}
div.deck-container.collapsed li:nth-child(2) {
-webkit-transform: translate(-100%, 2px);
-moz-transform: translate(-100%, 2px);
-ms-transform: translate(-100%, 2px);
-o-transform: translate(-100%, 2px);
transform: translate(-100%, 2px);
}
div.deck-container.collapsed li:nth-child(3) {
-webkit-transform: translate(-200%, 4px);
-moz-transform: translate(-200%, 4px);
-ms-transform: translate(-200%, 4px);
-o-transform: translate(-200%, 4px);
transform: translate(-200%, 4px);
}
working example