一个很简单的进度条
用一个简单的css属性就能实现:cilp
clip:rect(top,right,bottom,left)
先写一个小程序来解释
.box {
width: 200px;
height: 20px;
background:#ccc;
border-radius:10px;
position:relative
}
.clip {
position: absolute;
width: 100%;
height: 100%;
clip: rect(0px,100px,20px,0px);
background: red;
border-radius:10px;
}
</style>
<div class='box'>
<span class='clip'></span>
</div>
显示效果:
给.clip加上position:absolute;width:100%;height:100%;相对于在box里加上一个一样宽高的盒子,背景为红色;
rect(top,right,bottom,left),相对于控制这个盒子显示的面积,通过改变距离right的值,使显示的面积变大