<!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 {
font-family: Arial, sans-serif;
background: #f5f5f5;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
perspective: 1000px;
}
.carousel-container {
width: 300px;
height: 400px;
position: relative;
transform-style: preserve-3d;
animation: rotate 15s infinite linear;
}
.carousel-item {
position: absolute;
width: 100%;
height: 100%;
background: white;
border-radius: 10px;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
font-weight: bold;
color: white;
transition: transform 0.5s ease;
backface-visibility: hidden;
}
.carousel-item:nth-child(1) {
background: linear-gradient(45deg, #ff9a9e, #fad0c4);
transform: rotateY(0deg) translateZ(400px);
}
.carousel-item:nth-child(2) {
background: linear-gradient(45deg, #a1c4fd, #c2e9fb);
transform: rotateY(60deg) translateZ(400px);
}
.carousel-item:nth-child(3) {
background: linear-gradient(45deg, #ffecd2, #fcb69f);
transform: rotateY(120deg) translateZ(400px);
}
.carousel-item:nth-child(4) {
background: linear-gradient(45deg, #84fab0, #8fd3f4);
transform: rotateY(180deg) translateZ(400px);
}
.carousel-item:nth-child(5) {
background: linear-gradient(45deg, #a6c1ee, #fbc2eb);
transform: rotateY(240deg) translateZ(400px);
}
.carousel-item:nth-child(6) {
background: linear-gradient(45deg, #d4fc79, #96e6a1);
transform: rotateY(300deg) translateZ(400px);
}
@keyframes rotate {
from {
transform: rotateY(0deg);
}
to {
transform: rotateY(360deg);
}
}
.download-btn {
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
padding: 10px 20px;
background: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
text-decoration: none;
}
.download-btn:hover {
background: #45a049;
}
.credit {
position: absolute;
bottom: 70px;
left: 50%;
transform: translateX(-50%);
color: #666;
font-size: 12px;
}
</style>
</head>
<body>
<div class="carousel-container">
<div class="carousel-item">项目 1</div>
<div class="carousel-item">项目 2</div>
<div class="carousel-item">项目 3</div>
<div class="carousel-item">项目 4</div>
<div class="carousel-item">项目 5</div>
<div class="carousel-item">项目 6</div>
</div>
<a href="#" class="download-btn" id="downloadBtn">下载代码</a>
<script>
document.getElementById('downloadBtn').addEventListener('click', function() {
// 创建Blob对象
const content = document.documentElement.outerHTML;
const blob = new Blob([content], {type: 'text/html'});
// 创建下载链接
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = '3d-carousel.html';
// 触发下载
document.body.appendChild(a);
a.click();
// 清理
setTimeout(() => {
document.body.removeChild(a);
URL.revokeObjectURL(url);
}, 100);
});
</script>
</body>
</html>
3D垂直滚动轮播效果
于 2025-06-02 15:10:52 首次发布
8120

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



