Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="trigger">
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>
  <div class="item"></div>


                $brand-one: #85dbda;
$brand-two: #f53;
$brand-three: #123;
$brand-light: #fff;
$brand-dark: #0c162d;
$brand-grey: #637192;
body {
  // background-color: $brand-dark;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
.trigger {
  display: grid; 
grid-template-columns: 1fr; 
grid-template-rows: 1fr; 
grid-column-gap: 0px;
grid-row-gap: 0px; 
align-items: center;
justify-items: center;
> * { grid-area: 1 / 1 / 2 / 2; } 
.item {
  background-color: $brand-one;
  width: 300px;
  height: 300px;
  border-radius: 3em;
  border: 1px solid;

button {
  position: absolute;
bottom: 30px;
left: 30px;
// width: 100%;


                console.clear(); // Start with a clean console on refesh
// Get all the cards
let cards = gsap.utils.toArray(".item");
// Collect the cards that have moved
let shifted = [];
// Set inital state to all the cards
gsap.set(".item", {
  zIndex: (index, target, targets) => targets.length - index,
  scale: (index) => 1 - index * 0.1,
  xPercent: (index) => -10 * index
const tl = gsap.timeline({
  paused: true,

function scaleUp(elm) {
  // Add frist card to sifted array then remove it from cards array 
  // Animate closer to the front, {
    scale: "+=0.1",
    xPercent: "+=10",
    stagger: 0.1

function rotateAway(elm) {
  // Set shifted cards current z-index - 1
  gsap.set(shifted, {
    zIndex: "-=1"
  // And animate them away, {
    rotate: "-=2",
    y: "+=10",
    x: "-=10",
    delay: 0.5,
    stagger: 0.1

tl.from(".item", {
  x: () => window.innerWidth / 2, // Animate from the side of the screen to there main postion (middle)
  stagger: {
    each: 1,
    onStart: function () {
    onComplete: function () {

document.querySelector('button').addEventListener("click", function() {