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>
相关推荐
腾讯TNTWeb前端团队38 分钟前
helux v5 发布了,像pinia一样优雅地管理你的react状态吧
前端·javascript·react.js
范文杰4 小时前
AI 时代如何更高效开发前端组件?21st.dev 给了一种答案
前端·ai编程
拉不动的猪4 小时前
刷刷题50(常见的js数据通信与渲染问题)
前端·javascript·面试
拉不动的猪4 小时前
JS多线程Webworks中的几种实战场景演示
前端·javascript·面试
FreeCultureBoy5 小时前
macOS 命令行 原生挂载 webdav 方法
前端
uhakadotcom6 小时前
Astro 框架:快速构建内容驱动型网站的利器
前端·javascript·面试
uhakadotcom6 小时前
了解Nest.js和Next.js:如何选择合适的框架
前端·javascript·面试
uhakadotcom6 小时前
React与Next.js:基础知识及应用场景
前端·面试·github
uhakadotcom6 小时前
Remix 框架:性能与易用性的完美结合
前端·javascript·面试
uhakadotcom6 小时前
Node.js 包管理器:npm vs pnpm
前端·javascript·面试