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

Save Automatically?

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="wrap">
    <h2>Keyframe Animations</h2>
    <div id="myAnim3">
        <div></div>
    </div>
    <p class="info">Keyframe animation with <span class="code">translateX(80px)</span>,
        <span class="code">rotateZ(180deg)</span> and <span class="code">animation-delay: 500ms</p>
    <div id="myAnim4">
        <div></div>
    </div>
    <p class="info">Keyframe animation with <span class="code">animation-delay: -500ms</span></p>
    <p>Example 4</p>
    <div id="myBounce">
        <div></div>
    </div>
    <p class="info">A negative Y value in the cubic-bezier curve can result in a bouncing effect.</span>
    <p>Example 5</p>
    <div id="myAnim5">
        <div class="one"><p>1</p></div>
        <div class="two"><p>2</p></div>
        <div class="three"><p>3</p></div>
        <div class="four"><p>4</p></div>
    </div>
    <p class="info">This is a 3D animation that rotates the cube by 90 degrees every 2 seconds with
        <span class="code">animation-timing-function: ease-in-out</span></p>
    <p>Example 6</p>
    <div id="myAnim6">
        <div class="one"><p>1</p></div>
        <div class="two"><p>2</p></div>
        <div class="three"><p>3</p></div>
        <div class="four"><p>4</p></div>
    </div>
    <p class="info">This is a 3D animation that rotates the cube 360 degrees with
        <span class="code">animation-timing-function: linear</span></p>
    <p>To hide the backs of your elements/images, you can set
        <span class="code">backface-visibility: hidden;</span></p>
</div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Nunito:400,300);

html {
  body {
    background: #494E5A;
    color: #f7f1ee;
    font: 300 14px 'Nunito', sans-serif;

    .wrap {
      margin : 1em auto;
      padding: 0 2em 1em;

      a {
        color: coral;
        text-decoration: none;
        &:hover {
          border-bottom: 1px dotted coral;
        }
        &:active, &:focus, &:visited {
          color: coral;
          text-decoration: none;
        }
      }
      
      h1, h2, h3, p, span, a {
        font-weight: 300;
      }
      
      h1 {
        margin: 0;
      }
      
      h2 {
        margin: 1.5em 0 0 0;
      }

      p {
        margin: 1.5em 0 1em;
        &.info {
          display: inline-block;
          left: 176px;
          margin: 0;
          padding: 0;
          position: relative;
          top: -70px;
          white-space: normal;
          width: 560px;
          line-height: 1.75;
        }
      }

      .code {
        background: #dfdfdf;
        border-radius: 3px;
        color: #666666;
        display: inline;
        font-family: monospace;
        padding: 0.1em .25em;
      }
      
      #myAnim1, #myAnim2, #myAnim3, #myBounce, #myAnim4, 
      #myAnim5, #myAnim6, #myAnim7, #myTransform1, #myTransform2, 
      #myTransform3, #myTransform4, #noTransform
      {
        min-height: 80px;
        min-width: 80px;
        div {
          background:       #1FAB31;
          background-image: url("https://moduscreate.com/wp-content/themes/moduscreate-web/images/default-blog-image.jpg");
          background-size:  contain;
          border: 1px dashed #999;
          height: 80px;
          line-height: 80px;
          margin: 1em 0;
          opacity: 0.8;
          position: relative;
          text-align: center;
          width: 80px;
          p {
            line-height: 1em;
            margin: 0.5em 0;
            text-shadow: 1px 1px 1px #000000;
          }
        }
      }

      #myAnim3 {
        -webkit-animation-name:            mySquare;
        -webkit-animation-delay:           500ms;
        -webkit-animation-duration:        4s;
        -webkit-animation-iteration-count: infinite;
        -webkit-animation-timing-function: ease-in-out;
        -webkit-transform-origin:          40px 40px;
        /*
         *  "ease-in-out" is a keyword used to describe a cubic-bezier function.
         *  You can also define your own cubic-bezier curves
         */
        -webkit-animation-timing-function: cubic-bezier(.5, 0, .5, 1);

        -moz-animation-name:            mySquare;
        -moz-animation-delay:           500ms;
        -moz-animation-duration:        4s;
        -moz-animation-iteration-count: infinite;
        -moz-animation-timing-function: ease-in-out;
        -moz-animation-timing-function: cubic-bezier(.5, 0, .5, 1);
        -moz-transform-origin:          40px 40px;
        animation-name:            mySquare;
        animation-delay:           500ms;
        animation-duration:        4s;
        animation-iteration-count: infinite;
        animation-timing-function: ease-in-out;
        animation-timing-function: cubic-bezier(.5, 0, .5, 1);
        transform-origin:          40px 40px;
      }

      #myAnim4 {
        -webkit-animation-name:            mySquare;
        /*
         *  Using a negative value in animation-delay will
         *  result in the animation behaving as though
         *  that time had already passed.
         */
        -webkit-animation-delay:           -500ms;
        -webkit-animation-duration:        4s;
        -webkit-animation-iteration-count: infinite;
        -webkit-animation-timing-function: cubic-bezier(.5, 0, .5, 1);
        -webkit-transform-origin:          40px 40px;
        -moz-animation-name:            mySquare;
        -moz-animation-delay:           -500ms;
        -moz-animation-duration:        4s;
        -moz-animation-iteration-count: infinite;
        -moz-animation-timing-function: cubic-bezier(.5, 0, .5, 1);
        -moz-transform-origin:          40px 40px;
        animation-name:            mySquare;
        animation-delay:           -500ms;
        animation-duration:        4s;
        animation-iteration-count: infinite;
        animation-timing-function: cubic-bezier(.5, 0, .5, 1);
        transform-origin:          40px 40px;
      }

      // Animation with keyframes for the "rolling" square
      @-webkit-keyframes mySquare {
        0%       { -webkit-transform: translateX(0px) rotateZ(0deg); }
        50%      { -webkit-transform: translateX(80px) rotateZ(180deg); }
        100%     { -webkit-transform: translateX(0px) rotateZ(0deg); }
        // You can shortcut "0%" and "100%" as "from" and "to"
        from, to { -webkit-transform: translateX(0px) rotateZ(0deg); }
      }
      @-moz-keyframes mySquare {
        from, to { -moz-transform: translateX(0px) rotateZ(0deg); }
        50%      { -moz-transform: translateX(80px) rotateZ(180deg); }
      }
      @keyframes mySquare {
        from, to { transform: translateX(0px) rotateZ(0deg); }
        50%      { transform: translateX(80px) rotateZ(180deg); }
      }

      #myBounce {
        position: relative;
        top: 68px; 

        div {
          margin-bottom: 2em;
          top: 0;
          -webkit-animation-name:            bounce;
          -webkit-animation-direction:       alternate;
          -webkit-animation-duration:        0.5s;
          -webkit-animation-iteration-count: infinite;
          -webkit-animation-timing-function: cubic-bezier(0, -0.37, 0.2, 0.9);
          /*  Note that time, X (0 and 0.9), can not have a negative
           *  value in the animation-timing-function.
           *  The Y values (-0.37 and 0.2), however, can.
           */
          -moz-animation-name:            bounce;
          -moz-animation-direction:       alternate;
          -moz-animation-duration:        0.5s;
          -moz-animation-iteration-count: infinite;
          -moz-animation-timing-function: cubic-bezier(0, -0.37, 0.2, 0.9);
          animation-name:            bounce;
          animation-direction:       alternate;
          animation-duration:        0.5s;
          animation-iteration-count: infinite;
          animation-timing-function: cubic-bezier(0, -0.37, 0.2, 0.9);
        }
      }
      // Animation for bouncing box
      @-webkit-keyframes bounce {
        0%   { -webkit-transform: scaleY(0.95) scaleX(1.05); top: 0; }
        15%  { -webkit-transform: scaleY(1) scaleX(1); }
        35%  { -webkit-transform: scaleY(1) scaleX(1); }
        75%  { -webkit-transform: scaleY(1.01) scaleX(0.97); }
        95%  { -webkit-transform: scaleY(1.04) scaleX(0.96); }
        100% { -webkit-transform: scaleY(1.05) scaleX(0.95); top: -80px; }
      }
      @-moz-keyframes bounce {
        0%   { -moz-transform: scaleY(0.95) scaleX(1.05); top: 0; }
        15%  { -moz-transform: scaleY(1) scaleX(1); }
        35%  { -moz-transform: scaleY(1) scaleX(1); }
        75%  { -moz-transform: scaleY(1.01) scaleX(0.97); }
        95%  { -moz-transform: scaleY(1.04) scaleX(0.96); }
        100% { -moz-transform: scaleY(1.05) scaleX(0.95); top: -80px; }
      }
      @keyframes bounce {
        0%   { transform: scaleY(0.95) scaleX(1.05); top: 0; }
        15%  { transform: scaleY(1) scaleX(1); }
        35%  { transform: scaleY(1) scaleX(1); }
        75%  { transform: scaleY(1.01) scaleX(0.97); }
        95%  { transform: scaleY(1.04) scaleX(0.96); }
        100% { transform: scaleY(1.05) scaleX(0.95); top: -80px; }
      }

      #myAnim5 {
        -webkit-animation-name:            myCube;
        -webkit-animation-duration:        8s;
        -webkit-animation-iteration-count: infinite;
        -webkit-transform-origin:          40px 40px 0;
        -webkit-transform-style:           preserve-3d;
        -webkit-animation-timing-function: ease-in-out;
        -moz-animation-name:            myCube;
        -moz-animation-duration:        8s;
        -moz-animation-iteration-count: infinite;
        -moz-transform-origin:          40px 40px 0;
        -moz-transform-style:           preserve-3d;
        -moz-animation-timing-function: ease-in-out;
        animation-name:            myCube;
        animation-duration:        8s;
        animation-iteration-count: infinite;
        transform-origin:          40px 40px 0;
        transform-style:           preserve-3d;
        animation-timing-function: ease-in-out;
        div {
          margin: 0;
          position: absolute;
        }
        // Use transforms to make sure all sides face the correct way
        .one   {
          -webkit-transform: translateZ(40px);
          -moz-transform: translateZ(40px);
          transform: translateZ(40px);
        }
        .two   {
          -webkit-transform: rotateY(90deg) translateZ(40px);
          -moz-transform: rotateY(90deg) translateZ(40px);
          transform: rotateY(90deg) translateZ(40px);
        }
        .three {
          -webkit-transform: rotateY(180deg) rotateX(0deg) translateZ(40px);
          -moz-transform: rotateY(180deg) rotateX(0deg) translateZ(40px);
          transform: rotateY(180deg) rotateX(0deg) translateZ(40px);
        }
        .four  {
          -webkit-transform: rotateY(270deg) translateZ(40px);
          -moz-transform: rotateY(270deg) translateZ(40px);
          transform: rotateY(270deg) translateZ(40px);
        }
      }
      // Animation for first spinning cube
      @-webkit-keyframes myCube {
        0%    { -webkit-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
        25%   { -webkit-transform: rotateY(-90deg); }
        50%   { -webkit-transform: rotateY(-180deg); }
        75%   { -webkit-transform: rotateY(-270deg); }
        100%  { -webkit-transform: rotateY(-360deg); }
      }
      @-moz-keyframes myCube {
        0%    { -moz-transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
        25%   { -moz-transform: rotateY(-90deg); }
        50%   { -moz-transform: rotateY(-180deg); }
        75%   { -moz-transform: rotateY(-270deg); }
        100%  { -moz-transform: rotateY(-360deg); }
      }
      @keyframes myCube {
        0%    { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
        25%   { transform: rotateY(-90deg); }
        50%   { transform: rotateY(-180deg); }
        75%   { transform: rotateY(-270deg); }
        100%  { transform: rotateY(-360deg); }
      }

      #myAnim6 {
        -webkit-animation-name: myCube2;
        -webkit-animation-duration: 4s;
        -webkit-animation-iteration-count: infinite;
        -webkit-transform-origin: 40px 40px 0;
        -webkit-transform-style: preserve-3d;
        -webkit-animation-timing-function: linear;
        -moz-animation-name: myCube2;
        -moz-animation-duration: 4s;
        -moz-animation-iteration-count: infinite;
        -moz-transform-origin: 40px 40px 0;
        -moz-transform-style: preserve-3d;
        -moz-animation-timing-function: linear;
        animation-name: myCube2;
        animation-duration: 4s;
        animation-iteration-count: infinite;
        transform-origin: 40px 40px 0;
        transform-style: preserve-3d;
        animation-timing-function: linear;
        div {
          margin: 0;
          position: absolute;
          -webkit-backface-visibility: hidden;
          -moz-backface-visibility: hidden;
          backface-visibility: hidden;
        }
        // Use transforms to make sure all sides face the correct way
        .one   {
          -webkit-transform: translateZ(40px);
          -moz-transform: translateZ(40px);
          transform: translateZ(40px);
        }
        .two   {
          -webkit-transform: rotateY(90deg) translateZ(40px);
          -moz-transform: rotateY(90deg) translateZ(40px);
          transform: rotateY(90deg) translateZ(40px);
        }
        .three {
          -webkit-transform: rotateY(180deg) rotateX(0deg) translateZ(40px);
          -moz-transform: rotateY(180deg) rotateX(0deg) translateZ(40px);
          transform: rotateY(180deg) rotateX(0deg) translateZ(40px);
        }
        .four  {
          -webkit-transform: rotateY(270deg) translateZ(40px);
          -moz-transform: rotateY(270deg) translateZ(40px);
          transform: rotateY(270deg) translateZ(40px);
        }
      }
      // Animation for second rotating cube
      @-webkit-keyframes myCube2 {
        from  { -webkit-transform: rotateY(0deg); }
        to    { -webkit-transform: rotateY(-360deg); }
      }
      @-moz-keyframes myCube2 {
        from  { -moz-transform: rotateY(0deg); }
        to    { -moz-transform: rotateY(-360deg); }
      }
      @keyframes myCube2 {
        from  { transform: rotateY(0deg); }
        to    { transform: rotateY(-360deg); }
      }
    }
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console