88 lines
2.5 KiB
HTML
88 lines
2.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
<title>点击翻动</title>
|
|
<style>
|
|
/* The flip card container - set the width and height to whatever you want.
|
|
We have added the border property to demonstrate that the flip itself
|
|
goes out of the box on hover (remove perspective if you don't want the
|
|
3D effect */
|
|
.flip-card {
|
|
width: 100px;
|
|
height: 100px;
|
|
perspective: 1000px; /* Remove this if you don't want the 3D effect */
|
|
background-color: transparent;
|
|
}
|
|
|
|
/* This container is needed to position the front and back side */
|
|
.flip-card-inner {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
/* text-align: center; */
|
|
transition: transform 0.8s;
|
|
transform-style: preserve-3d;
|
|
}
|
|
|
|
/* Do an horizontal flip when you move the mouse over the flip box container */
|
|
/* .flip-card:hover .flip-card-inner, */
|
|
.flip .flip-card-inner {
|
|
transform: rotateY(180deg);
|
|
}
|
|
|
|
/* Position the front and back side */
|
|
.flip-card-front,
|
|
.flip-card-back {
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 100%;
|
|
-webkit-backface-visibility: hidden; /* Safari */
|
|
backface-visibility: hidden;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
/* Style the front side (fallback if image is missing) */
|
|
.flip-card-front {
|
|
background-color: dodgerblue;
|
|
color: white;
|
|
}
|
|
|
|
/* Style the back side */
|
|
.flip-card-back {
|
|
transform: rotateY(180deg);
|
|
background-color: dodgerblue;
|
|
color: yellow;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>点击翻动</h1>
|
|
<h2>作者:赵鑫</h2>
|
|
<div id="card" class="flip-card">
|
|
<div class="flip-card-inner">
|
|
<div class="flip-card-front">
|
|
<h1>正面</h1>
|
|
</div>
|
|
<div class="flip-card-back">
|
|
<h1>背面</h1>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script>
|
|
card.onclick = function () {
|
|
if (!card.classList.contains("flip")) {
|
|
card.classList.add("flip");
|
|
setTimeout(function () {
|
|
card.classList.remove("flip");
|
|
}, 2000);
|
|
}
|
|
};
|
|
</script>
|
|
</body>
|
|
</html>
|