$card-width: 180px; $card-outer-width: $card-width; ul { white-space: nowrap; /* allows the inline blocks to stick in a long line, not wrap like masonry. */ } li { width: $card-width; margin: 0; background: #fc0; opacity: 0.1; @include transition( margin-left 800ms, opacity 800ms ); } /* ONE CARD WIDE */ div { width: $card-outer-width; } li { margin-left: -100%; /* the bit that makes it all work. Each card has a default margin that makes it fold over itself, stacking them on top of each other */ } .pointer { margin-left: 0; opacity: 1; } .pointer+li { margin-left: 0; } /* TWO CARDS WIDE */ @media (min-width: $card-outer-width*4) { div { width: $card-outer-width*2; } li { margin-left: -50%; } .pointer+li { margin-left: 0; opacity: 1; } .pointer+li+li { margin-left: 0; } } /* THREE CARDS WIDE */ @media (min-width: $card-outer-width*5) { div { width: $card-outer-width*3; } li { margin-left: -33.333%; } .pointer+li+li { margin-left: 0; opacity: 1; } .pointer+li+li+li { margin-left: 0; } } /* FOUR CARDS WIDE */ @media (min-width: $card-outer-width*6) { div { width: $card-outer-width*4; } li { margin-left: -25%; } .pointer+li+li+li { margin-left: 0; opacity: 1; } .pointer+li+li+li+li { margin-left: 0; } } /* not so interesting formatting */ * { -webkit-box-sizing: border-box; box-sizing: border-box; } body { background: #eee; font-family: sans-serif; font-size: 16px; color: #999; } div { position: relative; margin: 20px auto 0; padding: 0; background: #fff; box-shadow: inset 0 1px 1px 1px rgba(0,0,0,0.1); counter-reset: cards; } ul { margin: 0; padding: 0; } li { position: relative; display: inline-block; list-style: none; height: 250px; padding: 0; counter-increment: cards; } li:before { content: counter(cards); display: block; position: absolute; top: 50%; left: 0; right: 0; margin-top: -0.5em; color: rgba(255,255,255,0.7); font-size: 120px; line-height: 1; text-align: center; } .pointer { box-shadow: inset 0 0 0 10px #fa0; } .pointer:after { content: '.pointer'; display: block; position: absolute; top: 12px; left: 12px; color: #f90; } .button { position: absolute; left: -0.25em; top: 50%; width: 2em; height: 2em; margin-top: -1em; padding: 0.5em; color: #fff; background: #999; border-radius: 50%; line-height: 1; text-align: center; font-family: impact; cursor: pointer; } .button-forward { left: auto; right: -0.25em; } .description { padding: 10px 20px; }