Last active
August 20, 2021 08:51
-
-
Save mindon/c1d23a14df250a92bf716ef51b94b993 to your computer and use it in GitHub Desktop.
pure css for a simple flipping card
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* <div class="dual"><div class="box"><div onclick="this.parentElement.classList.add('flipped')">current</div><div onclick="this.parentElement.classList.remove('flipped')">current</div></div></div> */ | |
.dual { | |
max-width: 100%; | |
position: relative; | |
margin: 2rem 0; | |
perspective: 1280px; | |
} | |
.dual:hover { | |
z-index: 999; | |
} | |
.dual>.box { | |
width: 100%; | |
height: 256px; | |
position: relative; | |
transform-style: preserve-3d; | |
transition: transform 1.5s ease 0s; | |
} | |
.dual>.box>div { | |
display: block; | |
position: absolute; | |
top: 0; | |
-webkit-backface-visibility: hidden !important; | |
backface-visibility: hidden !important; | |
width: 100%; | |
height: 100%; | |
overflow: hidden; | |
cursor: pointer; | |
} | |
.dual>.box>div:hover { | |
box-shadow: 0 6px 12px 4px rgba(66, 120, 218, 0.2); | |
border-radius: 6px; | |
} | |
.dual>.box>div:active { | |
box-shadow: 0 3px 6px 2px rgba(66, 120, 218, 0.1); | |
border-radius: 6px; | |
margin-top: 2px; | |
} | |
.dual>.box>div:last-child { | |
transform: rotateY(-180deg); | |
} | |
.dual>.box.flipped { | |
transform: rotateY(180deg); | |
} | |
.dual>.box>div * { | |
pointer-events: none; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment