<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D图片阴影翻转动画</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
font-family: Arial, sans-serif;
perspective: 1000px;
}
.gallery {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 40px;
max-width: 1200px;
padding: 20px;
}
.flip-card {
width: 300px;
height: 400px;
position: relative;
transform-style: preserve-3d;
transition: transform 1s;
cursor: pointer;
}
.flip-card:hover {
transform: rotateY(180deg);
}
.flip-card-front, .flip-card-back {
position: absolute;
width: 100%;
height: 100%;
backface-visibility: hidden;
border-radius: 15px;
overflow: hidden;
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}
.flip-card-front {
background: #fff;
display: flex;
justify-content: center;
align-items: center;
transform-style: preserve-3d;
}
.flip-card-front::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg, rgba(255,255,255,0.1), rgba(255,255,255,0.3));
transform: translateZ(30px);
}
.flip-card-img {
width: 90%;
height: 90%;
object-fit: cover;
border-radius: 10px;
transform: translateZ(50px);
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
transition: all 0.5s;
}
.flip-card:hover .flip-card-img {
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.flip-card-back {
background: linear-gradient(135deg, #2c3e50, #4ca1af);
color: white;
transform: rotateY(180deg);
padding: 30px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
text-align: center;
}
.flip-card-title {
font-size: 24px;
margin-bottom: 15px;
transform: translateZ(50px);
}
.flip-card-desc {
font-size: 16px;
line-height: 1.6;
margin-bottom: 20px;
transform: translateZ(30px);
}
.flip-card-btn {
padding: 10px 25px;
background: rgba(255, 255, 255, 0.2);
border: 2px solid white;
color: white;
border-radius: 50px;
font-size: 16px;
cursor: pointer;
transition: all 0.3s;
transform: translateZ(40px);
}
.flip-card-btn:hover {
background: rgba(255, 255, 255, 0.3);
transform: translateZ(40px) translateY(-5px);
}
.footer {
position: fixed;
bottom: 20px;
width: 100%;
text-align: center;
color: white;
text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}
.footer a {
color: #4fc3f7;
text-decoration: none;
transition: color 0.3s;
}
.footer a:hover {
color: #fff;
text-decoration: underline;
}
@media (max-width: 768px) {
.gallery {
gap: 20px;
}
.flip-card {
width: 250px;
height: 350px;
}
}
</style>
</head>
<body>
<div class="gallery">
<!-- 第一个3D翻转卡片 -->
<div class="flip-card">
<div class="flip-card-front">
<img src="https://source.unsplash.com/random/600x800?mountain" alt="山脉" class="flip-card-img">
</div>
<div class="flip-card-back">
<h2 class="flip-card-title">壮丽山脉</h2>
<p class="flip-card-desc">探索世界上最壮观的山脉景观,感受大自然的鬼斧神工。从喜马拉雅到阿尔卑斯,每一座山峰都有它独特的故事。</p>
<button class="flip-card-btn">了解更多</button>
</div>
</div>
<!-- 第二个3D翻转卡片 -->
<div class="flip-card">
<div class="flip-card-front">
<img src="https://source.unsplash.com/random/600x800?ocean" alt="海洋" class="flip-card-img">
</div>
<div class="flip-card-back">
<h2 class="flip-card-title">蔚蓝海洋</h2>
<p class="flip-card-desc">潜入深海世界,探索神秘的海底景观。海洋覆盖了地球表面的71%,蕴藏着无数未知的生命和美景。</p>
<button class="flip-card-btn">了解更多</button>
</div>
</div>
<!-- 第三个3D翻转卡片 -->
<div class="flip-card">
<div class="flip-card-front">
<img src="https://source.unsplash.com/random/600x800?forest" alt="森林" class="flip-card-img">
</div>
<div class="flip-card-back">
<h2 class="flip-card-title">神秘森林</h2>
<p class="flip-card-desc">漫步在古老的森林中,呼吸新鲜空气,聆听自然的声音。森林是地球的肺,也是无数生物的家园。</p>
<button class="flip-card-btn">了解更多</button>
</div>
</div>
</div>
<div class="footer">
<p>HTML5 3D图片阴影翻转动画</p>
</div>
<script>
// 为每个卡片添加随机延迟动画
document.querySelectorAll('.flip-card').forEach((card, index) => {
card.style.transitionDelay = `${index * 0.1}s`;
// 点击卡片也可以翻转
card.addEventListener('click', function() {
this.classList.toggle('flipped');
});
});
// 预加载图片
window.addEventListener('load', function() {
document.querySelectorAll('.flip-card-img').forEach(img => {
img.style.opacity = '1';
});
});
</script>
</body>
</html>

383

被折叠的 条评论
为什么被折叠?



