html设计(两种常见的充电效果)

第一种

完整代码:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
padding: 0;
margin: 0;
}
.box{
width: 800px;
height: 800px;
background-color: black;
margin: 20px auto;
padding-top: 20px;
position: relative;
}
.battery{
width: 200px;
height: 320px;
background-color:white;
margin-top: 200px;
margin-left: 300px;
border-radius: 15px 15px 0px 0px;
position: relative;
/* top: 20px; */
}
.battery::before{
content: "";
width: 50px;
height: 20px;
background-color:white;
position: absolute;
top: -20px;
left: 38%;
}
.battery::after{
content: "";
position: absolute;
top: 90%;
left: 0;
right: 0;
bottom: 0;
background-image: linear-gradient(to bottom,#7abcff 0%,#00BCD4
44%,#2196F3 100%);
animation:change 10s linear infinite ;
}
@keyframes change{
0%{
top: 100%;
filter: hue-rotate(90deg);
}
95%{
top: 5%;
border-radius: 0;
}
100%{
top: 0%;
border-radius: 15px 15px 0px 0px;
filter: hue-rotate(0deg);
}
}
.cover{
width: 100%;
height: 100%;
/* background-color: #00BCD4; */
border-radius: 15px 15px 0px 0px;
position: absolute;
top: 0;
left: 0;
z-index: 1;
overflow: hidden;
}
.cover::before{
content: "";
width: 400px;
height: 400px;
background-color: rgba(255, 255, 255, 0.8);
position: absolute;
left: -50%;
border-radius: 42% 40%;
animation: coverBefore 10s linear infinite;
}
@keyframes coverBefore{
0%{
transform: rotate(0deg);
bottom: 0%;
}
100%{
transform: rotate(360deg);
bottom: 100%;
}
}
.cover::after{
content: "";
width: 400px;
height: 400px;
background-color: rgba(255, 255, 255, 0.7);
position: absolute;
left: -50%;
border-radius: 42% 40%;
animation: coverAfter 10s linear infinite;
}
@keyframes coverAfter{
0%{
transform: rotate(30deg);
bottom: 2%;
}
100%{
transform: rotate(360deg);
bottom: 95%;
}
}
    </style>
</head>
<body>
    <div class="box">
    <div class="battery">
    <div class="cover"></div>
</body>
</html>

第二种

完整代码:

html 复制代码
<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<title>充电效果</title>

<style>

*{

padding: 0;

margin: 0;

}

/* .box{

width: 1000px;

height:1000px;

background-color: black;

margin: 20px auto;

padding-top: 20px;

position: relative;

} */

.contrast{

width: 70%;

height: 70%;

background-color:black;

position: absolute;

top: 20px;

left: 20%;

filter: contrast(15);

animation: hueRotate 5s linear infinite;

}

@keyframes hueRotate{

0%{

filter: contrast(15) hue-rotate(0);

}

100%{

filter: contrast(15) hue-rotate(360deg);

}

}

.circle{

width: 300px;

height: 300px;

/* background-color: #2196F3; */

position: absolute;

top: 0;

left: 50%;

margin-left: -150px;

filter: blur(8px);

animation: circleRotate 5s linear infinite;

}

@keyframes circleRotate{

0%{

transform: rotate(0);

}

100%{

transform: rotate(360deg);

}

}

.circle::before{

content: "";

width: 200px;

height: 200px;

background-color: #00ff6f;

position: absolute;

top: 50%;

left: 50%;

border-radius: 42% 38% 64% 49%/45%;

transform: translate(-50%,-50%);

}

.circle::after{

content: "";

width: 180px;

height: 178px;

background-color: black;

position: absolute;

top: 50%;

left: 50%;

border-radius: 50%;

transform: translate(-50%,-50%);

}

.number{

width: 200px;

height: 200px;

color: white;

font-size: 30px;

position: absolute;

top: 9%;

left: 55%;

z-index: 1;

line-height: 200px;

text-align: center;

margin-left: -100px;

}

.bubble_home{

width: 150px;

height: 50px;

background-color: #00ff6f;

position: absolute;

bottom: 0;

left: 45%;

border-radius: 150px 150px 15px 15px;

filter: blur(8px);

}

.bubble{

/* width: 20px;

height: 20px;

background-color:#00ff6f;

border-radius: 100%; */

position: absolute;

left: 50%;

bottom: 0;

z-index: 1;

animation:bubbleMoveUp 5s ease-in-out infinite ;

}

@keyframes bubbleMoveUp{

0%{

bottom: 0;

}

100%{

bottom: calc(100% - 260px);

}

}

.bubble:nth-child(1){

width: 20px;

height: 20px;

background-color:#00ff6f;

border-radius: 100%;

animation-duration: 5s;

animation-delay: 1s;

left: 50%;

}

.bubble:nth-child(2){

width: 18px;

height: 18px;

background-color:#00ff6f;

border-radius: 100%;

animation-duration: 7s;

animation-delay: 3s;

left: 47%;

}

.bubble:nth-child(3){

width: 22px;

height: 22px;

background-color:#00ff6f;

border-radius: 100%;

animation-duration: 3s;

animation-delay: 0.5s;

left: 51%;

}

.bubble:nth-child(4){

width: 18px;

height: 18px;

background-color:#00ff6f;

border-radius: 100%;

animation-duration: 4s;

animation-delay: 0s;

left: 50%;

}

.bubble:nth-child(5){

width: 20px;

height: 18px;

background-color:#00ff6f;

border-radius: 100%;

animation-duration: 7.5s;

animation-delay: 3.6s;

left: 48%;

}

.bubble:nth-child(6){

width: 21px;

height: 21px;

background-color:#00ff6f;

border-radius: 100%;

animation-duration: 8s;

animation-delay: 1.5s;

left: 50%;

}



</style>

</head>

<body>

<div class="box">

</div>

<div class="number">95.3%</div>

<div class="contrast">

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<div class="bubble"></div>

<span class="bubble_home"></span>

<div class="circle"></div>

</div>

</div>

</body>

</html>
相关推荐
敲啊敲952710 分钟前
5.npm包
前端·npm·node.js
brrdg_sefg24 分钟前
Rust 在前端基建中的使用
前端·rust·状态模式
m0_748230941 小时前
Rust赋能前端: 纯血前端将 Table 导出 Excel
前端·rust·excel
qq_589568101 小时前
Echarts的高级使用,动画,交互api
前端·javascript·echarts
黑客老陈2 小时前
新手小白如何挖掘cnvd通用漏洞之存储xss漏洞(利用xss钓鱼)
运维·服务器·前端·网络·安全·web3·xss
正小安2 小时前
Vite系列课程 | 11. Vite 配置文件中 CSS 配置(Modules 模块化篇)
前端·vite
暴富的Tdy2 小时前
【CryptoJS库AES加密】
前端·javascript·vue.js
neeef_se2 小时前
Vue中使用a标签下载静态资源文件(比如excel、pdf等),纯前端操作
前端·vue.js·excel
m0_748235613 小时前
web 渗透学习指南——初学者防入狱篇
前端