Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <div class="icons initial h-screen bg-gray-200 justify-between py-3 px-5">
  
  <svg id="icon1" width="13" height="20" viewBox="0 0 320 512" title="chess-bishop">
  <path d="M8 287.88c0 51.64 22.14 73.83 56 84.6V416h192v-43.52c33.86-10.77 56-33 56-84.6 0-30.61-10.73-67.1-26.69-102.56L185 285.65a8 8 0 0 1-11.31 0l-11.31-11.31a8 8 0 0 1 0-11.31L270.27 155.1c-20.8-37.91-46.47-72.1-70.87-92.59C213.4 59.09 224 47.05 224 32a32 32 0 0 0-32-32h-64a32 32 0 0 0-32 32c0 15 10.6 27.09 24.6 30.51C67.81 106.8 8 214.5 8 287.88zM304 448H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h288a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z" />
</svg>
  
  
<svg id="icon2" width="15" height="20" viewBox="0 0 384 512"  title="chess-knight">
  <path d="M19 272.47l40.63 18.06a32 32 0 0 0 24.88.47l12.78-5.12a32 32 0 0 0 18.76-20.5l9.22-30.65a24 24 0 0 1 12.55-15.65L159.94 208v50.33a48 48 0 0 1-26.53 42.94l-57.22 28.65A80 80 0 0 0 32 401.48V416h319.86V224c0-106-85.92-192-191.92-192H12A12 12 0 0 0 0 44a16.9 16.9 0 0 0 1.79 7.58L16 80l-9 9a24 24 0 0 0-7 17v137.21a32 32 0 0 0 19 29.26zM52 128a20 20 0 1 1-20 20 20 20 0 0 1 20-20zm316 320H16a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h352a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16z" />
</svg>
  
  
<svg id="icon3" width="18" height="20" viewBox="0 0 448 512" title="chess-king">
  <path d="M400 448H48a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h352a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm16-288H256v-48h40a8 8 0 0 0 8-8V56a8 8 0 0 0-8-8h-40V8a8 8 0 0 0-8-8h-48a8 8 0 0 0-8 8v40h-40a8 8 0 0 0-8 8v48a8 8 0 0 0 8 8h40v48H32a32 32 0 0 0-30.52 41.54L74.56 416h298.88l73.08-214.46A32 32 0 0 0 416 160z" />
</svg>
  
  
<svg id="icon4" width="20" height="20" viewBox="0 0 512 512" title="chess-queen">
  <path d="M256 112a56 56 0 1 0-56-56 56 56 0 0 0 56 56zm176 336H80a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h352a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm72.87-263.84l-28.51-15.92c-7.44-5-16.91-2.46-22.29 4.68a47.59 47.59 0 0 1-47.23 18.23C383.7 186.86 368 164.93 368 141.4a13.4 13.4 0 0 0-13.4-13.4h-38.77c-6 0-11.61 4-12.86 9.91a48 48 0 0 1-93.94 0c-1.25-5.92-6.82-9.91-12.86-9.91H157.4a13.4 13.4 0 0 0-13.4 13.4c0 25.69-19 48.75-44.67 50.49a47.5 47.5 0 0 1-41.54-19.15c-5.28-7.09-14.73-9.45-22.09-4.54l-28.57 16a16 16 0 0 0-5.44 20.47L104.24 416h303.52l102.55-211.37a16 16 0 0 0-5.44-20.47z" />
</svg>
</div>

<div id="content" class="bg-gray-400">
  <h1>Content starts here</h1>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed convallis tristique sem. </p>
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed convallis tristique sem.  Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi lacinia molestie dui. </p>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Signika+Negative:300,400&display=swap');

body { 
  font-family: "Signika Negative", sans-serif; 
  font-weight: 300;
  margin: 0;
  min-height: 300vh;
  padding: 0;
}

.icons {
  display: flex;
  position: relative;
  width: 100vw;
  
  svg {
    position: relative;
  }
}

.icons.initial {
  display: block;
  svg {
    position: absolute;
  }
  
  #icon1 {
    top: 0;
    left: 0;
    width: 94px;
    height: 150px;
  }
  
  #icon2 {
    top: 0;
    right: 0;
    width: 113px;
    height: 150px;
  }
  
  #icon3 {
    bottom: 0;
    left: 0;
    width: 131px;
    height: 150px;
  }
  
  #icon4 {
    bottom: 0;
    right: 0;
    width: 150px;
    height: 150px;
  }
}


              
            
!

JS

              
                /**
There are four icons equally spaced across the top of
the page using flexbox. They are part of the site's nav.

When the page loads, these icons are enlarged and placed
at four corners of the viewport.

As the user scrolls down, each icon scales down and moves
into place where flexbox has put them.
**/

let flipCtx;

function anim() {
  // revert context when anim() is run more than once
  flipCtx && flipCtx.revert();

  // create a context that contains the flip tween
  flipCtx = gsap.context(() => {
    // reset props and add the .initial class back to reset
    // the icons to their original locations. This is needed
    // for when flipCtx.revert() is called
    gsap.set('.icons svg, .icons', { clearProps: 'all' })
    document.querySelector('.icons').classList.add('initial')
    
    const container = document.querySelector('.icons')
    
    // Set state of icons as they'll start out on page load
    const state = Flip.getState(".icons svg");
    
    // Remove the class that positions the
    // icons in four corners and enlarges
    container.classList.remove('initial')
    
    // Create the Flip tween
    const flip = Flip.from(state, { duration: 6, scale: true });

    // Set up the scrolltrigger
    ScrollTrigger.create({
      trigger: container,
      endTrigger: "#content",
      pin: true,
      pinSpacing: true,
      start:"bottom 100%",
      end: "100px top",
      scrub: 1.5,
      markers: true,
      animation: flip,
    });
  });
}

// Init the animation
anim();

// listen for window resize events
window.addEventListener("resize", anim);

              
            
!
999px

Console