flip hover

In this example below you will see how to do a flip hover with some HTML / CSS and Javascript

Hover over the red box to see it rotate in three dimensional space.

Thumbnail
This awesome code was written by 96naveen, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 96naveen ©
  • HTML
  • CSS
  • JavaScript
    <div class="container">
  <div class="card">
    <div class="front">HOVER ME</div>
    <div class="back">This is the back face.</div>
  </div>
</div>

/*Downloaded from https://www.codeseek.co/96naveen/flip-hover-LEqwLM */
    body {
  color: #555;
  font-size: 1.1em;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

hr {
  margin: 50px 0;
}

.container {
  margin: 40px auto;
  width: 300px;
  border: 1px solid #eee;
  -webkit-perspective: 800px;
  perspective: 800px;
}

.card {
  -webkit-transition: all .3s ease-out;
  transition: all .3s ease-out;
  width: 300px;
  height: 500px;
  position: relative;
  -webkit-transform-style: preserve-3d;
  transform-style: preserve-3d;
}

.container:hover .card {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

.front,
.back {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  position: absolute;
  top: 0;
  left: 0;
  width: 300px;
  height: 500px;
  text-align: center;
  color: white;
  line-height: 500px;
  font-weight: bold;
}

.front {
  background-color: maroon;
  z-index: 2;
}

.back {
  z-index: 1;
  background-color: #7f8c8d;
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}


/*Downloaded from https://www.codeseek.co/96naveen/flip-hover-LEqwLM */
    

Comments