Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add card flip animation using HTML, CSS, and JS
  • Loading branch information
obaidur9696 committed May 19, 2025
commit ddf5d5694b3457965365807874110ff86dcc0927
25 changes: 25 additions & 0 deletions projects/card-flip-animation/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Flip Card Animation</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="card-container">
<div class="card" onclick="flipCard(this)">
<div class="card-front">
<h2>Front Side</h2>
<p>Click to flip!</p>
</div>
<div class="card-back">
<h2>Back Side</h2>
<p>More details here.</p>
</div>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions projects/card-flip-animation/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function flipCard(cardElement) {
cardElement.classList.toggle('flipped');
}
52 changes: 52 additions & 0 deletions projects/card-flip-animation/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}

body {
height: 100vh;
background: linear-gradient(135deg, #74ebd5, #9face6);
display: flex;
align-items: center;
justify-content: center;
font-family: Arial, sans-serif;
}

.card-container {
perspective: 1000px;
}

.card {
width: 300px;
height: 200px;
position: relative;
transform-style: preserve-3d;
transition: transform 0.8s;
cursor: pointer;
}

.card-front,
.card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 20px;
box-shadow: 0 8px 20px rgba(0,0,0,0.2);
background-color: white;
}

.card-back {
transform: rotateY(180deg);
background-color: #1775d4;
}

.card.flipped {
transform: rotateY(180deg);
}