用css画进度条

查看效果


index:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Title</title>
    <link rel="stylesheet" href="css.css">

</head>
<body>
    <div style="width: 30%;margin: 10% auto">
        <div class="progress" style="--percent:10"></div><br/>
        <div class="progress" style="--percent:40"></div><br/>
        <div class="progress" style="--percent:60"></div><br/>
    </div>
</body>
</html>

js:

.progress{
    position: relative;
    border-radius: 30px;
    line-height: 30px;
    text-align: center;
    background: #de0002;
    color: #fff;
}
.progress::before{
    content: "";
    position: absolute;
    left: 0;
    border-radius: inherit;
    width: calc(1%*var(--percent));
    height: 100%;
    background: #680001;
}
.progress::after{
    counter-reset: progress var(--percent);
    content: counter(progress)'%';
    position: relative;
}


关键词:
上一篇 下一篇


读后有收获可以支付宝请作者喝枸杞,有疑问也可以加作者讨论:





友情链接
@寅春树 豫ICP备20020705号 Powered by Thinkcmfx