1、实现方式
1、把具体的所占整体的百分比,写在第二个div中;
2、把动画效果和颜色写在第三个div中。
(content-box:用于表达100%的柱子;rate-box:用于表达此项所占的百分比;color-animation:用于实现具体的动画效果。)
2、完整代码
xml
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.content-box {
margin: 100px auto;
width: 265px;
height: 10px;
background: #36596C;
}
.rate-box {
height: 100%;
}
.color-animation {
height: 100%;
animation: move 2s ease forwards;
background: linear-gradient(270deg, #1890FF 0%, #1EE7E7 100%);
}
@keyframes move {
0% {
width: 0%;
}
100% {
width: 100%;
}
}
</style>
</head>
<body>
<div class="content-box">
<div class="rate-box" style="width: 60%;">
<div class="color-animation"></div>
</div>
</div>
</body>
</html>