Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="button-group">
  <p>Use a quicker transition on <code>:hover</code> for a more dynamic feel.</p>
  <button class="standard-timing">Standard</button>
  <button class="dynamic-timing">Dynamic</button>
  <div class="button-grid">
    <button class="dynamic-timing">1</button>
    <button class="dynamic-timing">2</button>
    <button class="dynamic-timing">3</button>
    <button class="dynamic-timing">4</button>
    <button class="dynamic-timing">5</button>
    <button class="dynamic-timing">6</button>
    <button class="dynamic-timing">7</button>
    <button class="dynamic-timing">8</button>
    <button class="dynamic-timing">9</button>
    <button class="dynamic-timing">10</button>
    <button class="dynamic-timing">11</button>
    <button class="dynamic-timing">12</button>
    <button class="dynamic-timing">13</button>
    <button class="dynamic-timing">14</button>
    <button class="dynamic-timing">15</button>
    <button class="dynamic-timing">16</button>
    <button class="dynamic-timing">17</button>
    <button class="dynamic-timing">18</button>
    <button class="dynamic-timing">19</button>
    <button class="dynamic-timing">20</button>
  </div>
</div>
<div class="button-group">
  <p>Combine transitions and animations to enable different in/out effects.</p>
  <button class="slide-up">Up</button>
  <button class="slide-down">Down</button>
  <button class="slide-in-out">In/Out</button>
</div>
<div class="button-group">
  <p>Transition pseudo elements for creative fills, and use delays to transition different properties.</p>
  <button class="fill-in">Fill In</button>
  <button class="fill-fade">Fill In + Fade Out</button>
</div>
              
            
!

CSS

              
                $blue: hsl(200, 100%, 50%);

/* Layout */

html {
  text-align: center;
}

div.button-group {
  margin-bottom: 3em;
}

p {
  font-size: 1.25em;
}


/* Base button styles */

button {
  position: relative;
  z-index: 1;
  background: $blue;
  color: white;
  font-size: 2em;
  padding: 0.5em 1em;
  margin: 0.5em;
  border: 1px solid $blue;
  cursor: pointer;

  &:hover {
    background: white;
    color: $blue;
  }
}

/* :hover timing */

button.standard-timing {
  transition: 600ms;
}

button.dynamic-timing {
  // Default transition
  transition: 600ms;
  
  // Shorter duration on :hover
  &:hover {
    transition: 200ms;
  }
  
  /* Smaller buttons for grid example */

}

.button-grid {
  display: inline-block;
  margin-top: 1em;
  
  button.dynamic-timing {
    border: 0;
    display: block;
    float: left;
    font-size: 1em;
    margin: 0;
    padding: 0.3em 0.1em;
    width: 2em;
    transition: 1200ms;
    
    &:hover {
      transition: 50ms;
    }
  }
}

/* Slide effect */

button.slide {
  // Background is a 2x height gradient
  background: linear-gradient($blue, $blue 50%, white 50%, white);
  background-size: 100% 200%;
}

button.slide-up {
  @extend button.slide;
  background-position: 50% 0%;
  transition: 300ms;
  
  // Move background up on :hover
  &:hover {
    background-position: 50% 100%;
  }
}

button.slide-down {
  @extend button.slide;
  background-position: 50% 0%;
  transition: 300ms;
  
  // Move background down on :hover
  &:hover {
    background-position: 50% -100%;
  }
}

/* Animation on :hover */

button.slide-in-out {
  // Inherits values from .slide-down
  @extend button.slide-down;
  
  // On :hover, play the animation
  &:hover {
    animation: slide-up-in 300ms;
  }
}

/* Slide up keyframes */

@keyframes slide-up-in {
  0% {
    // Start from bottom position
    background-position: 50% 0%;
  }
  100% {
    // End at top, which appears the same as .slide-down hover state
    background-position: 50% 100%;
  }
}

/* Pseudo element fill */

button.fill {
  position: relative;
  z-index: 1;
  transform: translateZ(0);
  transition: 300ms;
  
  /* :before element fill */
  &:before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: -1;
  }
}

button.fill-in {
  @extend button.fill;

  /* "Out" styles */
  &:before {
    opacity: 0;
    background: white;
    transform: scale(0.01);
    // When transitioning out, keep opacity at 1 for most of the duration with 250ms delay
    transition: transform 300ms, opacity 50ms 250ms;
  }

  &:hover {
    background: $blue;
    
    /* "In" styles */
    &:before {
      opacity: 1;
      transform: scale(1);
      // Fade in with shorter duration to show more of the transform
      transition: transform 300ms, opacity 50ms;
    }
  }
}

button.fill-fade {
  // Inherits values from .fill-in
  @extend button.fill-in;
  
  /* "Out" styles */
  &:before {
    // Keep transform property in hover state until opacity is finished transitioning with 300ms delay
    transition: transform 0ms 300ms, opacity 300ms;
  }
}
              
            
!

JS

              
                
              
            
!
999px

Console