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

              
                <div  class="qualities">
        <div class="title"><p>Things I am good at</p></div>

        <div class="q q1" onclick="flipQ1()">
          <div class="q1front">
            <p>1 front</p>
          </div>
          <div class="q1back">
            <p>GSAP, obviously (:</p>
          </div>
        </div>

        <div class="q q2" onclick="flipQ2()">
          <div class="q2front">
            <p>2 front</p>
          </div>
          <div class="q2back">
            <p>2 back</p>
          </div>
        </div>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.3/TweenMax.min.js"></script> <!-- gsap plugin -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <!-- jquery plugin -->
              
            
!

CSS

              
                .qualities {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 70px 150px 150px 150px;
  width: 90%;
  margin: 15px auto;
  border-radius: 15px;
  justify-items: stretch;
  backgound-color: #D7D7D7;
}

.title {
  grid-column: 1 / span 3;
  background-color: #101010;
  font-size: 25px;
  color: white;
  text-align: center;
  padding: 7px;
  border-top-right-radius: 15px;
  border-top-left-radius: 15px;
}

.q {
  background-color: #D7D7D7;
}

.q1 {
  width: 100%;
}

.q p {
  color: black;
  font-size: 30px;
  text-decoration: none;
  color: black;
  text-align: center;
}

.q1front, .q1back, .q2front, .q2back {
  backface-visibility: hidden;
  width: 30%; 
/*   Changing the width property to 100% makes the first card the right width, but the second card takes up the width of the entire page */
  height: 150px;
  position: absolute;
}

.q1back, .q2back {
  background-color: red;
}

.q1front, .q2front {
  background-color: green;
}

.q7 {
  border-bottom-left-radius: 15px;
}

.q9 {
  border-bottom-right-radius: 15px;
}
              
            
!

JS

              
                //First method
//this method uses the container to flip the entire thing

var q1 = $(".q1");
  var q1back = $(".q1back");
  var isTouch

  TweenMax.set(q1, {css:{
          transformStyle:"preserve-3d",
          z:0
        }}); 

  TweenMax.set(q1back, {css:{
    rotationY:-180
  }});

  function flipQ1(e) {
    TweenMax.to(q1, 1, {css:{
      rotationY:"+=180"
    }, onComplete:enableUI, ease:Bounce.easeOut});
    TweenMax.to(q1, 1, {css:{
      z:"-=100"},
      yoyo:true,
      repeat:1,
      ease:Power2.easeInOut
    });
  } 

  isTouch = ("touchstart" in document.documentElement);

  function enableUI() {
    if(isTouch){
      q1.one("touchend", onMouseDown);
    } else {
      q1.one("click", onMouseDown);
    }
  }

//End of first method

//Second method
//this method animates the front and back to flip the card, but leaves the container in place. 

var q2flip = new TimelineMax({paused:true, reversed:true})
  
  q2flip
  .from(".q2front", .5, {
    autoAlpha: 0,
    rotationY: 180, 
    ease:Bounce.easeInOut
    }, "cross")
  .to(".q2back", .5, {
    rotationY:180,
    autoAlpha: 0
    }, "cross")
  
  function flipQ2() {
q2flip.reversed() ? q2flip.play() : q2flip.reverse();
  }
              
            
!
999px

Console