通过css新特性实现进度条和自定义计数器
<!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>
.bar {
line-height: 20px;
background-color: #eee;
}
.bar::before {
counter-reset: progress var(--percent);
content: counter(progress) "%\2002";
display: block;
width: calc(1% * var(--percent));
color: #fff;
background-color: deepskyblue;
text-align: right;
}
body{
counter-reset: section;
}
h2{
counter-reset: subsection;
}
h2:before{
counter-increment:section;
content:counter(section) "、";
}
h4:before{
counter-increment:subsection;
content: counter(section) "." counter(subsection) "、";
}
</style>
</head>
<body>
<label for="">图片</label>
<div class="bar" style="--percent: 60;"></div>
<div>
<h2>123</h2>
<h4>321</h4>
<h4>321</h4>
<h2>ads</h2>
<h4>5516</h4>
<h4>132</h4>
</div>
</body>
</html>