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="cardspace">
  <h3>(tap or click on card to flip)</h3>
  <div class="card" onclick="flip()">
    <div class="front">
      <img alt="cat on computer says" src="https://twelvednotes.files.wordpress.com/2019/03/bella-on-keyboard_clearedbkgd80.jpg?w=2048" width="330">
      <div class="text-block" id="cap1">
        <h1>you wants laptop?</h1>
      </div>
    </div>
    <div class="back">
      <img alt="cat on blanket says" src="https://twelvednotes.files.wordpress.com/2019/03/i-know-my-place_recoloredrotated_2220x2220.jpg?w=2048" width="330">
      <div class="text-block">
        <h1>i am the <em>best</em>&ensp;laptop</h1>
      </div>
    </div>
  </div>
  <div id="title">
    <h2>a feline response to overtime on&nbsp;codepen</h2>
  </div>
</div>
              
            
!

CSS

              
                @import 'https://fonts.googleapis.com/css?family=Anton|Oswald'; /*note [i]*/
* {
  box-sizing: border-box;
}
body {
  background-color: #111;
  font-family: Impact, Anton, sans-serif; /*note [ii]*/
}
h1 {
  -webkit-text-stroke: 1px #111; /*note [iii]*/
  font-size: 1.75em;
}
h1, h2 {
  color: #EEE;
  line-height: 1.25;
}
h2, h3 {
  font-family: Oswald, Calibri, sans-serif;
  text-align: center;
}
h3 {
  color: #AAA;
  font-size: 1em;
  font-weight: 200;
}
em {
  font-style: italic; /*note [iv]*/
}
.cardspace {
  position: absolute;
  width: 20em;
  height: 29.5em;
  top: 50%;
  left: 50%;
  margin-top: -15em;
  margin-left: -10em; /*note [v]*/
  -webkit-perspective: 800; /*note [_]*/
  perspective: 800;
  cursor: pointer;
}
.card {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
  -webkit-transition: all 1s ease-in-out;
  transition: all 1s ease-in-out; /*note [_]*/
}
.card .front, .card .back {
  position: absolute;
  border-radius: 5%;
  box-shadow: .15em .15em .5em #999, -.05em -.05em .5em #999;
  overflow: hidden; /*note [_]*/
  width: 100%;
  height: 70%;
}
.card div {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.card .front .text-block { /*note [vi]*/
  position: absolute;
  top: 50%;
  right: 5%;
  text-align: right;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.card .back {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
  box-shadow: .25em .25em 3em #FFF;
  z-index: 10;
}
.card .back .text-block { /*note [vi]*/
  position: absolute;
  width: 50%;
  top: 25%;
  left: 10%;
  text-align: left;
}
.card.flipped {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}
.card.flipped #cap1 {
  visibility: hidden;
}
#title {
  position: absolute;
  width: 100%;
  left: 0%;
  bottom: -2%;
}
h2 {
  visibility: hidden;
}
.cardspace:hover h2 {
  visibility: visible;
}

/*** footnotes *** 
Three primary models for card flip
= James Doyle (jQuery toggle), at https://jsfiddle.net/james2doyle/qsQun/
= Shay Howe (CSS hover), at https://codepen.io/shayhowe/pen/Fvjnf 
= Eddy Sims (CSS hover), at https://codepen.io/shayhowe/pen/Fvjnf 

CLEANED UP VERSION FORTHCOMING:
// Must pair with onclick attribute in HTML + .card.flipped rulesets in CSS, thanks to model by James Doyle at JSFiddle. 

[i] Embedding Google Fonts on CodePen was modeled by Eddy Sims's "Pure CSS Card Flip" (https://codepen.io/edeesims/pen/iGDzk), which also inspired my query [v] about repositioning card.

[ii] The Impact font, familiar from Cheezburger and Grumpy Cat captions, is trademarked and not available on my mobile display; Anton, by Vernon Adams, is the best open-source approximation I've found so far. Runners-up: Oswald (Bold) and Fira Sans Extra Condensed (Extra Bold).

[iii] Text outlining parroted (without grasp of workings) from https://www.codesdope.com/blog/article/adding-outline-to-text-using-css/ + https://css-tricks.com/adding-stroke-to-web-text/ 

[iv] This rule faux-italicizes fonts that lack native italics; thanks to https://css-tricks.com/almanac/properties/f/font-style/. I have added &ensp; in HTML to get enough space after italicized text.

[v] This ruleset centers the card for any screen size or browser width; thanks to https://css-tricks.com/quick-css-trick-how-to-center-an-object-exactly-in-the-center/. 

[vi] The text-block class superimposes captions on images; thanks to https://www.w3schools.com/howto/howto_css_image_text_blocks.asp

FURTHER READING 
-- On chaining selectors: https://css-tricks.com/multiple-class-id-selectors/ + https://frontstuff.io/should-you-chain-or-extend-css-classes
-- On coding playgrounds: https://www.sitepoint.com/7-code-playgrounds/
-- Context/caveat re: viewports setup: https://blog.codepen.io/documentation/views/full-page-view/ 
***/
              
            
!

JS

              
                function flip() {
  $(".card").toggleClass("flipped");
}
              
            
!
999px

Console