JSFiddle - React, Tailwind, and code Playground
by amindunited
HTML
<div class="container">
<div class="box">
<div class="front">
Front
</div>
<div class="back">
Back
</div>
</div>
</div>
CSS
/*
.container {
width: 90vw;
height: 90vh;
position: relative;
margin: 0 auto 40px;
border: 1px solid #CCC;
}
.container:hover .box {
transform: rotateY(150deg);
}
.box {
width: 100%;
height: 100%;
position: absolute;
transform-style: preserve-3d;
transform-origin: 50% 50%;
transition: transform 1s;
}
.box > div {
width: 100%;
height: 100%;
position: absolute;
backface-visibility: hidden;
}
.front {
}
.back {
transform: rotateX(180deg);
}
*/
/*
*
.front {
background-color: rgba(256, 0, 0, .35);
}
.back {
background-color: rgba(0, 256, 0, .35);
}
*/
.container {
position: relative;
top: 50%;
left: 50%;
width: 300px;
height: 300px;
margin: -150px;
float: left;
perspective: 500px;
}
.box {
position: absolute;
width: 100%;
height: 100%;
box-shadow: 0 0 15px rgba(0,0,0,0.1);
transition: transform 1s;
transform-style: preserve-3d;
}
.container:hover .box {
transform: rotateY( 180deg ) ;
transition: transform 0.5s;
}
.front,
.back {
position: absolute;
height: 100%;
width: 100%;
background: white;
line-height: 300px;
color: #03446A;
text-align: center;
font-size: 60px;
border-radius: 5px;
backface-visibility: hidden;
}
.back {
background: #03446A;
color: white;
transform: rotateY( 180deg );
}