effect:
achieve:
1. Add a label, you can see that a li is a light bulb, you can have more points to ensure that the overall size can be larger than the width of the browser's default viewable area after setting the size.
<ul class="container">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
2. Set the basic style of the bottom box .container:
.container{
margin-top: 10px;
width: 100%;
height: 120px;
white-space: nowrap;
overflow: hidden;
}
white-space: nowrap; The child element li does not wrap and will continue to be arranged on the same line.
overflow: hidden; overflow hidden.
3. Set the style of li bulb:
.container li{
display: inline-block;
margin-top: 30px;
margin-right: 50px;
width: 15px;
height: 30px;
border-radius: 50%;
position: relative;
}
display: inline-block; Change to inline block element.
border-radius: 50%; Angle radian.
4. Set the lamp cap with double pseudo-classes:
.container li::after{
content: '';
position: absolute;
top: -5px;
left: 50%;
transform: translateX(-50%);
width: 20px;
height: 12px;
background-color: rgb(27, 27, 27);
box-shadow: inset 0 0 3px rgb(129, 129, 129);
border-radius: 10px;
}
left: 50%;
transform: translateX(-50%); center horizontally
box-shadow: inset 0 0 3px rgb(129, 129, 129); inner shadow
5. Set up wires with double pseudo-classes:
.container li::before{
content: '';
position: absolute;
top: -23px;
left: 15px;
width: 55px;
height: 30px;
border-bottom: 3px solid rgb(61, 61, 61);
border-radius: 50%;
}
border-bottom: 3px solid rgb(61, 61, 61);
border-radius: 50%; This way the border can present a crescent shape.
6. Set 4 animation effects to display different colors flashing:
@keyframes lan{
0%,100%{
background-color: rgba(4, 255, 242, 0.5);
}
50%{
background-color: rgb(4, 255, 242);
box-shadow: 0 0 10px rgb(4, 255, 242),
0 0 30px rgb(4, 255, 242),
0 0 50px rgb(4, 255, 242);
}
}
@keyframes huang{
0%,100%{
background-color: rgba(251, 255, 4,.5);
}
50%{
background-color: rgb(251, 255, 4);
box-shadow: 0 0 10px rgb(251, 255, 4),
0 0 12px rgb(251, 255, 4),
0 0 30px rgb(251, 255, 4);
}
}
@keyframes lv{
0%,100%{
background-color: rgba(33, 255, 4,.5);
}
50%{
background-color: rgb(33, 255, 4);
box-shadow: 0 0 10px rgb(33, 255, 4),
0 0 12px rgb(33, 255, 4),
0 0 30px rgb(33, 255, 4);
}
}
@keyframes zhi{
0%,100%{
background-color: rgba(255, 4, 255,.5);
}
50%{
background-color: rgb(255, 4, 255);
box-shadow: 0 0 10px rgb(255, 4, 255),
0 0 25px rgb(255, 4, 255),
0 0 40px rgb(255, 4, 255);
}
}
box-shadow: Shadow, adding it is equivalent to glowing.
7. Add animation properties to li in different positions:
.container li:nth-of-type(2n+1){
animation: lan 2s infinite;
}.container li:nth-child(2n+2){
animation: huang 2.2s infinite;
}.container li:nth-child(3n+3){
animation: zhi 1.8s infinite;
}
.container li:nth-child(4n+4){
animation: lv 2.8s infinite;
}
Complete code:
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
body{
background-color: rgb(0, 0, 0);
}
.container{
margin-top: 10px;
width: 100%;
height: 120px;
white-space: nowrap;
overflow: hidden;
}
.container li{
display: inline-block;
margin-top: 30px;
margin-right: 50px;
width: 15px;
height: 30px;
border-radius: 50%;
position: relative;
}
.container li::after{
content: '';
position: absolute;
top: -5px;
left: 50%;
transform: translateX(-50%);
width: 20px;
height: 12px;
background-color: rgb(27, 27, 27);
box-shadow: inset 0 0 3px rgb(129, 129, 129);
border-radius: 10px;
}
.container li::before{
content: '';
position: absolute;
top: -23px;
left: 15px;
width: 55px;
height: 30px;
border-bottom: 3px solid rgb(61, 61, 61);
border-radius: 50%;
}
.container li:nth-of-type(2n+1){
animation: lan 2s infinite;
}.container li:nth-child(2n+2){
animation: huang 2.2s infinite;
}.container li:nth-child(3n+3){
animation: zhi 1.8s infinite;
}
.container li:nth-child(4n+4){
animation: lv 2.8s infinite;
}
@keyframes lan{
0%,100%{
background-color: rgba(4, 255, 242, 0.5);
}
50%{
background-color: rgb(4, 255, 242);
box-shadow: 0 0 10px rgb(4, 255, 242),
0 0 30px rgb(4, 255, 242),
0 0 50px rgb(4, 255, 242);
}
}
@keyframes huang{
0%,100%{
background-color: rgba(251, 255, 4,.5);
}
50%{
background-color: rgb(251, 255, 4);
box-shadow: 0 0 10px rgb(251, 255, 4),
0 0 12px rgb(251, 255, 4),
0 0 30px rgb(251, 255, 4);
}
}
@keyframes lv{
0%,100%{
background-color: rgba(33, 255, 4,.5);
}
50%{
background-color: rgb(33, 255, 4);
box-shadow: 0 0 10px rgb(33, 255, 4),
0 0 12px rgb(33, 255, 4),
0 0 30px rgb(33, 255, 4);
}
}
@keyframes zhi{
0%,100%{
background-color: rgba(255, 4, 255,.5);
}
50%{
background-color: rgb(255, 4, 255);
box-shadow: 0 0 10px rgb(255, 4, 255),
0 0 25px rgb(255, 4, 255),
0 0 40px rgb(255, 4, 255);
}
}
</style>
</head>
<body>
<ul class="container">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</body>
</html>
to sum up:
Although it is not difficult to achieve, the effect is quite good.
Other articles:
Colorful streamer text html+css
bubble floating background special effect html+css
simple clock special effect html+css+js
cyberpunk style button html+css
imitating NetEase cloud official website carousel image html+css+js
water wave loading animation html+ css
navigation bar scrolling gradient effect html+css+js
book page turning html+css
3D stereo album html+css
neon drawing board effect html+css+js
remember some CSS attribute summary (1)
Sass summary notes
... etc.