我需要为一个项目制作一个“健康”进度条,其中绿色代表已填充的数据,红色代表未填充的数据。当红色部分为50%时,我得到了一个漂亮的圆形,但是一旦该值更改为其他任何值,边框半径就会出现问题。
目前这是我的代码:
HTML:
<div id="progressWrap">
<span class="progressRed"></span>
</div>
CSS:
#progressWrap {
width: 50px;
height: 50px;
display: block;
background-color: forestgreen;
-webkit-border-radius: 100%;
-moz-border-radius: 100%;
-ms-border-radius: 100%;
border-radius: 100%;
}
.progressRed {
width: 50%;
height: 50px;
float: right;
background-color: red;
border-bottom-right-radius: 25px;
border-top-right-radius: 25px;
}
progressRed类的宽度值将使用Jquery进行动态设置,或许我也可以改变border-radius以使其适应progressWrap?但我不知道如何计算在这种情况下需要的border-radius。
非常感谢您的帮助!