Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add card flip animation using HTML, CSS, and JavaScript#59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
obaidur9696 wants to merge1 commit intosahandghavidel:main
base:main
Choose a base branch
Loading
fromobaidur9696:feature/card-flip-animation
Open
Show file tree
Hide file tree
Changes fromall 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
25 changes: 25 additions & 0 deletionsprojects/card-flip-animation/index.html
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsprojects/card-flip-animation/script.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
function flipCard(cardElement) {
cardElement.classList.toggle('flipped');
}
52 changes: 52 additions & 0 deletionsprojects/card-flip-animation/style.css
View file
Open in desktop
Original file line numberDiff line numberDiff 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);
}

[8]ページ先頭

©2009-2025 Movatter.jp