JSFiddle - React, Tailwind, and code Playground
by anoopsuda
HTML
<div class="card">
<div class="card-face card-front">
<h3>John Doe</h3>
<p>UI / UX Designer</p>
<button>View Profile</button>
</div>
<div class="card-face card-back">
<h3>About John</h3>
<p>Creative designer with 5+ years of experience.</p>
<button>Contact</button>
</div>
</div>
CSS
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: #f5f5f5;
font-family: Arial, sans-serif;
}
/* Card container */
.card {
position: relative;
width: 280px;
height: 180px;
cursor: pointer;
}
/* Common face styles */
.card-face {
position: absolute;
inset: 0;
padding: 20px;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
transition: opacity 0.4s ease;
}
/* Front side */
.card-front {
background: #ffffff;
opacity: 1;
z-index: 2;
}
/* Back side */
.card-back {
background: #1e88e5;
color: #ffffff;
opacity: 0;
z-index: 1;
}
/* Hover effect */
.card:hover .card-front {
opacity: 0;
}
.card:hover .card-back {
opacity: 1;
}
/* Button styling */
button {
margin-top: 12px;
padding: 8px 14px;
border: none;
border-radius: 6px;
background: #1e88e5;
color: #fff;
cursor: pointer;
}
.card-back button {
background: #ffffff;
color: #1e88e5;
}