纯css实现夜晚的列车驶入效果
代码语言:html
所属分类:布局界面
代码描述:纯css实现夜晚的列车驶入效果
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<style>
* {
outline: none;
box-sizing: border-box;
}
:root {
--body-color: #dedddf;
--night-color: #1f1c1f;
}
html {
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
overflow: hidden;
}
body {
background-color: var(--body-color);
display: -webkit-box;
display: flex;
-webkit-box-align: center;
align-items: center;
height: 100vh;
-webkit-box-pack: center;
justify-content: center;
}
.container {
position: relative;
width: 500px;
height: 456px;
display: -webkit-box;
display: flex;
-webkit-box-pack: center;
justify-content: center;
-webkit-box-align: center;
align-items: center;
}
.container-wrapper {
position: absolute;
-webkit-clip-path: polygon(37% 0, 65% 0, 100% 100%, 0% 100%);
clip-path: polygon(37% 0, 65% 0, 100% 100%, 0% 100%);
width: 500px;
height: 450px;
background-color: var(--night-color);
}
.star-container {
width: 100%;
height: 100%;
display: -webkit-box;
display: flex;
position: absolute;
z-index: 1;
}
.stars {
flex-shrink: 0;
width: 100%;
height: 100%;
position: relative;
will-change: transform;
-webkit-animation: infinity-loop 5s infinite linear .1s both;
animation: infinity-loop 5s infinite linear .1s both;
}
.moon {
position: absolute;
width: 45px;
height: 45px;
background-color: var(--night-color);
top: 100px;
left: 180px;
border-radius: 50%;
box-shadow: -11px -11px 0 0 var(--body-color) inset;
-webkit-animation: moon 20s infinite linear .1s both;
animation: moon 20s infinite linear .1s both;
z-index: 2;
}
.star {
position: absolute;
background-color: var(--body-color);
z-index: 9;
}
.star:nth-child(1) {
right: 200px;
top: 60px;
border-radius: 50%;
width: 5px;
height: 5px;
}
.star:nth-child(2) {
right: 90px;
top: 40px;
border-left: 1px solid var(--body-color);
height: 10px;
}
.star:nth-child(2):before {
right: -5px;
top: 4px;
content: "";
position: absolute;
border-bottom: 1px solid var(--body-color);
width: 10px;
}
.star:nth-child(3) {
right: 314px;
top: 70px;
border-left: 2px solid var(--body-color);
height: 13px;
}
.star:nth-child(3):before {
right: -6px;
top: 5px;
content: "";
position: absolute;
border-bottom: 2px solid var(--body-color);
width: 13px;
}
.star:nth-child(4) {
right: 220px;
top: 120px;
width: 7px;
height: 7px;
border-radius: 50%;
}
.star:nth-child(5) {
right: 360px;
top: 130px;
border-radius: 50%;
width: 4px;
height: 4px;
}
.star:nth-child(6) {
right: 245px;
top: 70px;
border-radius: 50%;
width: 4px;
height: 4px;
}
.star:nth-child(7) {
right: 160px;
top: 100px;
border-left: 2px solid var(--body-color);
height: 15px;
}
.star:nth-child(7):before {
right: -7px;
top: 6px;
content: "";
position: absolute;
border-bottom: 2px solid var(--body-color);
width: 15px;
}
.star:nth-child(8) {
right: 200px;
top: 150px;
width: 3px;
height: 3px;
border-radius: 50%;
}
.star:nth-child(9) {
right: 290px;
top: 160px;
border-left: 1px solid var(--body-color);
height: 9px;
}
.star:nth-child(9):before {
right: -4px;
top: 4px;
content: &q.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0