How To Create Social Paper Flip Hover Animation With HTML & CSS

How To Create Social Paper Flip Hover Animation With HTML & CSS

CSS animations are a lot of fun; the beauty of them is that through many simple properties, you can create anything from an elegant fade in to a WTF-Pixar-would-be-proud effect. One CSS effect somewhere in between is the CSS flip effect, whereby there's content on both the front and back of a given container. This tutorial will show you show to create that effect in as simple a manner as possible. 

Step 1: HTML

he HTML structure to accomplish the two-sided effect is as you would expect it to be: 

  <div class="container">
    <a href="" class="social-container twitter">
      <div class="social-cube">
        <div class="front">
        Twitter
        </div>
        <div class="bottom">
        @deshamarbd
        </div>
      </div>
    </a>
  </div>

Step 2: CSS

*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
@import url("https://fonts.googleapis.com/css?family=Dosis");
body {
font-family: ‘Dosis’;
background: #295;
display: flex;
height: 100vh;
margin: 0;
justify-content: center;
align-items: center;
}
.container{
  margin: 300px auto;
}
.social-container{
  position: relative;
  width: 160px;
  height: 36px;
  display: block;
  font-size: 24px;
  transform-style: preserve-3d;
  padding: 8px;
}
.social-container .social-cube{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: translateZ(-18px);
  transition: all .6s;
}
.social-container .social-cube .front, .social-container .social-cube .bottom{
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  text-align: center;
  line-height: 36px;
  color: #fff;
}
.social-container .social-cube .front{
  transform: rotateX(0deg)translate(18px);
}
.social-container .social-cube .bottom{
  transform: rotateX(-90deg)translate(18px);
}
.social-container:hover .social-cube{
  transform: translateZ(-18px) rotateX(90deg);
}
.social-container.twitter .social-cube .front, .social-container.twitter .social-cube .back {
  background: #4099FF;
}
.social-container.twitter .social-cube .bottom {
background: #0d7eff;
}
.social-container.twitter:hover .social-cube .bottom {
background: #4099FF;
}
.social-container.twitter:hover .social-cube .front {
background: #73b4ff;
}