用css画进度条

看效果

index:

<!DOCTYPE html>
<html>
<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 style="--percent:10"></div><br/>
        <div style="--percent:40"></div><br/>
        <div style="--percent:60"></div><br/>
    </div>
</body>
</html>

css:

.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;
}


复制内容


评论


乖,登录后才可以留言! 登录

Copyright © 2020-2023 春藤技术,春藤建站 All Rights Reserved
备案号:豫ICP备20020705号 公网安备 51LA统计