css布局实现一个流星雨效果
代码语言:html
所属分类:动画
代码描述:css布局实现一个流星雨效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="http://repo.bfw.wiki/bfwrepo/css/aqua.min.css">
<style>
body {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background: radial-gradient(ellipse at bottom, #0d1d31 0%, #0c0d13 100%);
overflow: hidden;
}
.stars {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 120%;
transform: rotate(-45deg);
}
.star {
--star-color: var(--primary-color);
--star-tail-length: 6em;
--star-tail-height: 2px;
--star-width: calc(var(--star-tail-length) / 6);
--fall-duration: 9s;
--tail-fade-duration: var(--fall-duration);
position: absolute;
top: var(--top-offset);
left: 0;
width: var(--star-tail-length);
height: var(--star-tail-height);
color: var(--star-color);
background: linear-gradient(45deg, currentColor, transparent);
border-radius: 50%;
filter: drop-shadow(0 0 6px currentColor);
transform: translate3d(104em, 0, 0);
animation: fall var(--fall-duration) var(--fall-delay) linear infinite, tail-fade var(--tail-fade-duration) var(--fall-delay) ease-out infinite;
}
@media screen and (max-width: 750px) {
.star {
animation: fall var(--fall-duration) var(--fall-delay) linear infinite;
}
}
.star:nth-child(1) {
--star-tail-length: 6.57em;
--top-offset: 91.39vh;
--fall-duration: 9.677s;
--fall-delay: 6.465s;
}
.star:nth-child(2) {
--star-tail-length: 6.31em;
--top-offset: 33.87vh;
--fall-duration: 8.642s;
--fall-delay: 9.687s;
}
.star:nth-child(3) {
--star-tail-length: 7.06em;
--top-offset: 47.86vh;
--fall-duration: 8.147s;
--fall-delay: 8.012s;
}
.star:nth-child(4) {
--star-tail-length: 7.16em;
--top-offset: 64.73vh;
.........完整代码请登录后点击上方下载按钮下载查看
网友评论0