Created
June 15, 2022 08:44
-
-
Save DavidGarciaCat/d964d3163bce9021027b3dd2baad1acd to your computer and use it in GitHub Desktop.
CSS flip with text on Hover event
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<style> | |
body { | |
font-family: Arial, Helvetica, sans-serif; | |
} | |
.flip-card { | |
background-color: transparent; | |
width: 300px; | |
height: 300px; | |
perspective: 1000px; | |
} | |
.flip-card-inner { | |
position: relative; | |
width: 100%; | |
height: 100%; | |
text-align: center; | |
transition: transform 0.6s; | |
transform-style: preserve-3d; | |
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2); | |
} | |
.flip-card:hover .flip-card-inner { | |
transform: rotateY(-180deg); | |
} | |
.flip-card-front, .flip-card-back { | |
position: absolute; | |
width: 100%; | |
height: 100%; | |
-webkit-backface-visibility: hidden; | |
backface-visibility: hidden; | |
} | |
.flip-card-front { | |
background-color: #bbb; | |
color: black; | |
} | |
.flip-card-back { | |
background-color: #2980b9; | |
color: white; | |
transform: rotateY(180deg); | |
} | |
</style> | |
</head> | |
<body> | |
<h1>Card Flip with Text</h1> | |
<h3>Hover over the image below:</h3> | |
<div class="flip-card"> | |
<div class="flip-card-inner"> | |
<div class="flip-card-front"> | |
<img src="img_avatar.png" alt="Avatar" style="width:300px;height:300px;"> | |
</div> | |
<div class="flip-card-back"> | |
<h1>John Doe</h1> | |
<p>Architect & Engineer</p> | |
<p>We love that guy</p> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment