<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
overflow: hidden;
background: #000;
display: flex;
justify-content: center;
align-items: center;
}
.background {
position: absolute;
width: 100%;
height: 100%;
background: radial-gradient(circle, rgba(0, 0, 0, 0.8), #000);
overflow: hidden;
}
.stars {
position: absolute;
width: 100%;
height: 100%;
background: transparent;
background-image: url('https://www.transparenttextures.com/patterns/stardust.png');
animation: twinkling 200s infinite;
}
@keyframes twinkling {
0% { background-position: 0 0; }
100% { background-position: -10000px 5000px; }
}
/**
* 定义一个名为 twinkling 的关键帧动画
* 该动画用于创建闪烁或移动的背景效果
*/
@keyframes twinkling {
/* 动画开始时的背景位置 */
0% { background-position: 0 0; }
/* 动画结束时的背景位置,创造横向和纵向的移动效果 */
100% { background-position: -10000px 5000px; }
}
.shooting-star {
position: absolute;
top: 0;
left: 50%;
width: 2px;
height: 100px;
background: linear-gradient(45deg, white, rgba(255, 255, 255, 0));
animation: shooting 2s infinite;
}
@keyframes shooting {
0% {
transform: translateX(0) translateY(0) rotate(45deg);
opacity: 1;
}
100% {
transform: translateX(-1000px) translateY(1000px) rotate(45deg);
opacity: 0;
}
}
.content {
position: relative;
z-index: 1;
color: #fff;
font-family: Arial, sans-serif;
font-size: 2em;
text-align: center;
}
</style>
</head>
<body>
<div class="background">
<div class="stars"></div>
<div class="shooting-star"></div>
</div>
</body>
</html>
使用copilot插件1分钟生成css动画
最新推荐文章于 2025-04-24 15:54:03 发布