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

              
                <!-- animate.css -->
<!--
  the data attributes are set with defaults
  if transition('#animate') is called then these transitions will happen
  but the example buttons below dynamically change these data attributes to different transitions
  note the data-library-class entry, animate.css requires "animated" class
-->
<div class="example-container">
  <p>Animate.css example</p>
  <div id="animate" class="container" data-leave-class="fadeOut" data-enter-class="fadeIn" data-library-class="animated">
    <div id="animate1" class="box"></div>
    <div id="animate2" class="box hidden"></div>
  </div>

  <!-- these are the example buttons for animate.css transitions -->
  <div>
    <button id="animate_fade">fade</button>
    <button id="animate_fade_slide">fade slide</button>
    <button id="animate_bounce">bounce</button>
  </div>
</div>

<!-- animista -->
<!--
  the data attributes are set with defaults
  if transition('#animista') is called then these transitions will happen
  but the example buttons below dynamically change these data attributes to different transitions
  note there's no data-library-class entry, animista doesn't require one
-->
<div class="example-container">
  <p>Animista example</p>
  <div id="animista" class="container" data-leave-class="scale-out-center" data-enter-class="scale-in-center">
    <div id="animista1" class="box"></div>
    <div id="animista2" class="box hidden"></div>
  </div>

  <!-- these are the example buttons for animista transitions -->
  <div>
    <button id="animista_scale">scale</button>
    <button id="animista_slit">slit</button>
    <button id="animista_flicker">flicker</button>
  </div>
</div>
              
            
!

CSS

              
                html {
  box-sizing: border-box;
  font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;
}
*, *:before, *:after {
  box-sizing: inherit;
}

html,
body {
  padding: 0;
  margin: 0;
}
body {
  background-color: #1d1e22;
  display: flex;
  justify-content: center;
}

button {
  font-size: 16px;
  padding: 5px 10px;
}

.example-container {
  align-items: center;
  display: flex;
  flex-direction: column;
  
  p {
    color: #fff;
    margin: 10px;
  }
}

.container {
  align-items: center;
  background-color: #707070;
  border: {
    color: #C5C5C5;
    style: solid;
    width: 3px;
  }
  display: flex;
  height: 200px;
  justify-content: center;
  margin: 20px;
  overflow: hidden;
  width: 250px;
}

.box {
  border: {
    color: #333333;
    style: solid;
    width: 2px;
  }
  height: 100px;
  width: 100px;
}
#animate1,
#animista1{
  background-color: rebeccapurple;
}
#animate2,
#animista2 {
  background-color: #307B21;
}

.hidden {
  display: none !important;
}




/* ----------------------------------------------
 * Generated by Animista on 2019-3-20 23:56:28
 * w: http://animista.net, t: @cssanimista
 * ---------------------------------------------- */
.scale-in-center{animation:scale-in-center .5s cubic-bezier(.25,.46,.45,.94) both}
@keyframes scale-in-center{0%{transform:scale(0);opacity:1}100%{transform:scale(1);opacity:1}}
.scale-out-center{animation:scale-out-center .5s cubic-bezier(.55,.085,.68,.53) both}
@keyframes scale-out-center{0%{transform:scale(1);opacity:1}100%{transform:scale(0);opacity:1}}
.slit-in-vertical{animation:slit-in-vertical .45s ease-out both}
@keyframes slit-in-vertical{0%{transform:translateZ(-800px) rotateY(90deg);opacity:0}54%{transform:translateZ(-160px) rotateY(87deg);opacity:1}100%{transform:translateZ(0) rotateY(0)}}
.slit-out-vertical{animation:slit-out-vertical .5s ease-in both}
@keyframes slit-out-vertical{0%{transform:translateZ(0) rotateY(0);opacity:1}54%{transform:translateZ(-160px) rotateY(87deg);opacity:1}100%{transform:translateZ(-800px) rotateY(90deg);opacity:0}}
.flicker-in-1{animation:flicker-in-1 2s linear both}
@keyframes flicker-in-1{0%{opacity:0}10%{opacity:0}10.1%{opacity:1}10.2%{opacity:0}20%{opacity:0}20.1%{opacity:1}20.6%{opacity:0}30%{opacity:0}30.1%{opacity:1}30.5%{opacity:1}30.6%{opacity:0}45%{opacity:0}45.1%{opacity:1}50%{opacity:1}55%{opacity:1}55.1%{opacity:0}57%{opacity:0}57.1%{opacity:1}60%{opacity:1}60.1%{opacity:0}65%{opacity:0}65.1%{opacity:1}75%{opacity:1}75.1%{opacity:0}77%{opacity:0}77.1%{opacity:1}85%{opacity:1}85.1%{opacity:0}86%{opacity:0}86.1%{opacity:1}100%{opacity:1}}
.flicker-out-1{animation:flicker-out-1 2s linear both}
@keyframes flicker-out-1{0%{opacity:1}13.9%{opacity:1}14%{opacity:0;box-shadow:none}14.9%{opacity:0;box-shadow:none}15%{opacity:1}22.9%{opacity:1}23%{opacity:0;box-shadow:none}24.9%{opacity:0;box-shadow:none}25%{opacity:1}34.9%{opacity:1}35%{opacity:0;box-shadow:none}39.9%{opacity:0;box-shadow:none}40%{opacity:1}42.9%{opacity:1}43%{opacity:0;box-shadow:none}44.9%{opacity:0;box-shadow:none}45%{opacity:1}50%{opacity:1}54.9%{opacity:1}55%{opacity:0;box-shadow:none}69.4%{opacity:0;box-shadow:none}69.5%{opacity:1}69.9%{opacity:1}70%{opacity:0;box-shadow:none}79.4%{opacity:0;box-shadow:none}79.9%{opacity:1}80%{opacity:0;box-shadow:none}89.8%{opacity:0;box-shadow:none}89.9%{opacity:1;box-shadow:none}90%{opacity:0;box-shadow:none}100%{opacity:0}}
              
            
!

JS

              
                // https://daneden.github.io/animate.css/
// each button changes the enter/leave animations for the elements on demand
// this is just to provide dynamic transitions, project may not require this functionality
const animateContainer = document.querySelector('#animate');
document.querySelector('#animate_fade').addEventListener('click', function () {
  animateContainer.dataset.leaveClass = 'fadeOut';
  animateContainer.dataset.enterClass = 'fadeIn';
  
  transition('#animate');
});
document.querySelector('#animate_fade_slide').addEventListener('click', function () {
  animateContainer.dataset.leaveClass = 'fadeOutRight';
  animateContainer.dataset.enterClass = 'fadeInLeft';
  
  transition('#animate');
});
document.querySelector('#animate_bounce').addEventListener('click', function () {
  animateContainer.dataset.leaveClass = 'bounceOutUp';
  animateContainer.dataset.enterClass = 'bounceInDown';
  
  transition('#animate');
});

// http://animista.net/
// each button changes the enter/leave animations for the elements on demand
// this is just to provide dynamic transitions, project may not require this functionality
const animistaContainer = document.querySelector('#animista');
document.querySelector('#animista_scale').addEventListener('click', function () {
  animistaContainer.dataset.leaveClass = 'scale-out-center';
  animistaContainer.dataset.enterClass = 'scale-in-center';
  
	transition('#animista');
});
document.querySelector('#animista_slit').addEventListener('click', function () {
  animistaContainer.dataset.leaveClass = 'slit-out-vertical';
  animistaContainer.dataset.enterClass = 'slit-in-vertical';
  
	transition('#animista');
});
document.querySelector('#animista_flicker').addEventListener('click', function () {
  animistaContainer.dataset.leaveClass = 'flicker-out-1';
  animistaContainer.dataset.enterClass = 'flicker-in-1';
  
	transition('#animista');
});

var transition = function (target) {
	const container = document.querySelector(target);
	const elementA = container.querySelector(':first-child');
  const elementB = container.querySelector(':last-child');
  const leaveClass = container.dataset.leaveClass;
  const enterClass = container.dataset.enterClass;
	const libraryClass = container.dataset.libraryClass;
  const hiddenClass = 'hidden'; // assummption on actual hidden class name
  const leaving = elementA.classList.contains('hidden') ? elementB : elementA;
  const entering = elementA.classList.contains('hidden') ? elementA : elementB;
  
  // function called at animationend
  let leaveEnd = () => {
  	// leaving element has finished transition, so it gets hidden
  	leaving.classList.add(hiddenClass);
    // if there's a libray class we remove it with the leaving class
    // otherwise, just the leaving class is removed
    // this is cleanup in case transition is reversed
    libraryClass ?
	    leaving.classList.remove(libraryClass, leaveClass) :
      leaving.classList.remove(leaveClass);
      
    // remove listeners for animation/transition events on leaving element
    // this is cleanup so we don't get zombie events in case transition is reversed
    leaving.removeEventListener('animationend', leaveEnd);
    leaving.removeEventListener('transitionend', leaveEnd);
    
    // create listeners for animation/transition events on entering element
    // entering element is entering, so we need to know when it's done
    entering.addEventListener('animationend', enterEnd);
    entering.addEventListener('transitionend', enterEnd);
    
    // remove hidden class on entering element so it can be seen
    entering.classList.remove(hiddenClass);
    
    // add in necessary classes for entering element to actually enter
    // if there's a library class add that as well
    libraryClass ?
	    entering.classList.add(libraryClass, enterClass) :
      entering.classList.add(enterClass);
  };
  
  let enterEnd = () => {
  	// if there's a libray class we remove it with the entering class
    // otherwise, just the entering class is removed
    // this is cleanup in case transition is reversed
  	libraryClass ?
	  	entering.classList.remove(libraryClass, enterClass) :
      entering.classList.remove(enterClass);
      
    // remove listeners for animation/transition events on entering element
    // this is cleanup so we don't get zombie events in case transition is reversed
    entering.removeEventListener('animationend', enterEnd);
    entering.removeEventListener('transitionend', enterEnd);
  };
  
  // the leaving element is first, kicks off the entire process
  // these listeners wait for animation/transition end events to call leaveEnd function
  leaving.addEventListener('animationend', leaveEnd);
  leaving.addEventListener('transitionend', leaveEnd);
  
  // add in necessary classes for leaving element to actually leave
  // if there's a library class add that as well
  libraryClass ?
	  leaving.classList.add(libraryClass, leaveClass) :
    leaving.classList.add(leaveClass);
};
              
            
!
999px

Console