HTML5七夕情人节表白网页制作【3D雪花展开相册】HTML+CSS+JavaScript 程序员表白网页 简单的3D相册制作
以下是一个简单的HTML5页面示例,用于创建一个表白网页,包含3D旋转的雪花和展开相册的效果。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>七夕情人节表白</title>
<style>
/* 雪花样式 */
.snow {
position: fixed;
top: 0; left: 0;
pointer-events: none;
z-index: 1000;
}
.flake {
position: absolute;
top: 0;
color: #FFD700;
font-weight: bold;
font-family: 'Arial', sans-serif;
font-size: 10px;
overflow: hidden;
}
/* 相册展开样式 */
.album {
width: 200px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
margin-top: -100px;
margin-left: -100px;
transform-style: preserve-3d;
transform: translateZ(-100px) rotateX(90deg);
transition: transform 1s ease-in-out;
pointer-events: none;
}
.album.open {
transform: translateZ(-100px) rotateX(0);
}
.album img {
width: 100%;
height: 100%;
position: absolute;
backface-visibility: hidden;
transition: transform 1s ease-in-out;
}
.album img:first-child {
transform: rotateY(0deg) translateZ(100px);
}
.album.open img:first-child {
transform: rotateY(180deg) translateZ(100px);
}
/* 其他样式 */
body {
margin: 0;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background-color: #000;
color: #FFD700;
font-size: 20px;
text-shadow: 0 0 10px #FFD700;
}
</style>
</head>
<body>
<div class="snow">
<div class="flake">❤</div>
</div>
<div class="album">
<img src="image1.jpg" alt="Image 1">
<img src="image2.jpg" alt="Image 2">
<img src="image3.jpg" alt="Image 3">
</div>
<script>
// 雪花动画
function snowFall() {
const snow = document.querySelector('.snow');
const flake = document.querySelector('.flake');
let x = Math.random() * window.innerWidth;
let y = Math.random() * window.innerHeight;
let size = Math.random() * 10;
flake.style.left = x + 'px';
flake.style.top = y + 'px';
flake.style.fontSize = size + 'px';
snow.appendChild(flake.cloneNode(true));
}
setInterval(snowFall, 500);
// 相册展开动画
const album = document.querySelector('.album');
album.addEventListener('click', () => {
album.classList.add('open');
});
</script>
</body>
</html>
这段代码包含了一个简单的3D旋转雪花效果和点击相册触发的展开动画。你需要替换image1.jpg
, \`image2.jpg
评论已关闭