Flip card via HTML and CSS only. Short and simple, click on the the card below the see the animation.
DEMO
HTML
<label> <input type="checkbox" /> <div class="card"> <article class="front">Front</article> <article class="back">Back</article> </div> </label>
CSS
label {
-webkit-perspective: 1000px;
perspective: 1000px;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
display: block;
width: 250px;
height: 200px;
cursor: pointer;
}
.card {
position: relative;
height: 100%;
width: 100%;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-transition: all 600ms;
transition: all 600ms;
z-index: 20;
border-radius: 10px;
}
.card article {
position: absolute;
height: 100%;
width: 100%;
background: CadetBlue;
color: white;
text-align: center;
line-height: 200px;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
border-radius: 10px;
}
.card .back {
background: DarkBlue;
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
label:hover .card {
-webkit-transform: rotateX(20deg);
transform: rotateX(20deg);
box-shadow: 0 20px 20px rgba(50, 50, 50, 0.2);
}
input {
display: none;
}
:checked + .card {
transform: rotateX(180deg);
-webkit-transform: rotateX(180deg);
}
label:hover :checked + .card {
transform: rotateX(160deg);
-webkit-transform: rotateX(160deg);
box-shadow: 0 20px 20px rgba(255, 255, 255, 0.2);
}

Comments
Post a Comment