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

              
                <!-- 
Wrote a blog post about how it all works:
http://andymcfee.com/2012/08/24/css3-flip-cards/
-->

<div class="viewport">
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
  <div class="flip-card">
    <div class="card-front">
      Front!
    </div>
    <div class="card-back">
      Back!
    </div>
  </div>
  
</div>

              
            
!

CSS

              
                @import "compass/css3";

$default-transition-duration: 500ms;
$perspective: 300;

/***
* CSS3 FLIP CARDS
* Markup for an element that a user can hover to reveal content on the back, like a card
* Browser Support: Safari, Firefox, Chrome, IE8+, and Touch Devices; (IE9 and below will not have any flip effect but will just change on hover)
***/

.flip-card {
  display: block;
  position: relative;
  z-index: 1000;
  width: 100px; 
  height: 100px;
  
  .card-front,
  .card-back {
    @include backface-visibility(hidden);
    @include single-transition(transform);
    display: block;
    height: 100%;
    position: absolute;
    width: 100%; 
  }

  .card-front {
    @include transform3d(perspective($perspective) rotateY(0));
    z-index: 900;
  }

  .card-back {
    @include rotateY(-180deg); //Using rotate instead of transform prevents the back of the card from flipping on page load because transition is only targeting transform. Super sweet. 
     z-index: 800;
  }

  &:hover {
    .card-front { 
      @include transform(rotateY(180deg)); //No 3D fallback
      @include transform3d(perspective($perspective) rotateY(180deg)); 
    }
    .card-back { 
      z-index: 950; //No transform fallback
      @include transform(rotateY(0deg)); //No 3D fallback
      @include transform3d(perspective($perspective) rotateY(0deg)); 
    }
  }
}




/*** Just for show... ***/

.flip-card {
  @include text-shadow(1px 1px 0 rgba(darken(#1B8CE8, 20%), .8) );
  color: #fff;
  cursor: pointer;
  float: left;
  font-weight: bold;
  margin: 10px;
  text-align: center;
  text-transform: uppercase;
  min-width: 100px;
  max-width: 400px;
  
  .card-front,
  .card-back {
    @include border-radius(5px);
    @include box-shadow(1px 1px 2px rgba(darken(#1B8CE8, 20%), .8));
    @include box-sizing(border-box);
    border: 1px solid darken(#1B8CE8, 40%);
    padding: 40px 0;
  }

  .card-front {
    @include box-sizing(border-box);
    background-color: #499bea; // Old browsers
  	@include filter-gradient(#499bea, #207ce5, vertical);
		@include background-image(linear-gradient(top,  #499bea 0%,#207ce5 100%));

  }

  .card-back {
    @include box-shadow(0 0 20px rgba(darken(#1B8CE8, 10%), .8) inset);
		background-color: #478ce0; // Old browsers
		@include filter-gradient(#478ce0, #0263db, vertical); // IE6-9
		@include background-image(linear-gradient(top,  #478ce0 0%,#1168db 100%,#0263db 100%));
  } 
}



body {
  background-color: #e6f2f7; // Old browsers
  @include filter-gradient(#e6f2f7, #a0d8ef, horizontal); 
  @include background-image(radial-gradient(center, circle cover,  #e6f2f7 0%,#a0d8ef 100%));

}

.viewport {
  margin: 10px auto 0;
  width: 500px;
}

              
            
!

JS

              
                
              
            
!
999px

Console