react 写百分比的圆环

 <View className={styles.contentImages}>
            <View className={[styles.percentCircle, styles.percentCircleLeft]}>
              {classWrongScore > 0.5 ? <View className={styles.leftContent}
                style={{transform: `rotate(${180 * classWrongScore}deg)`}}
              > </View> :
                <View className={styles.leftContent}> </View>
              }
            </View>
            <View className={[styles.percentCircle, styles.percentCircleRight]}>
              {classWrongScore < 0.5 ?
                <View className={styles.rightContent}
                  style={{transform: `rotate(${360 * classWrongScore}deg)`}}
                > </View> :
                <View className={styles.rightContent} style={{background: '#fe8a1c'}}> </View>
              }
            </View>
            <View className={styles.textCircle}>
              <View className={styles.singleFieldFlow}>单场流水</View>
              <View className={styles.singleFieldFlow}>¥{numToMyriad(data.singleFieldFlow)}</View>
            </View>
          </View>
  .contentImages {
    position:relative;
    overflow: hidden;
    display:inline-block;
    //border: solid 4px #FF7818;
    width: 200px;
    height:200px;
    .singleFieldFlow {
      font-size: 12PX;
      font-weight: 500;
      color: #242424;
    }
  }
  
  .percentCircle {
    position:absolute;
    height:100%;
    background:#FF8B17;
    overflow: hidden;
  }
  .percentCircleRight {
    right:0;
    width:100px;
    border-radius: 0 100px 100px 0/0 100px 100px 0;
  }
  .percentCircleRight .rightContent{
    position: absolute;
    content: '';
    width: 100%;
    height: 100%;
    transform-origin:left center;
    transform: rotate(0deg);
    border-radius: 0 100px 100px 0/0 100px 100px 0;
    background:#F9C975;
  }
  .percentCircleLeft {
    width:102px;
    border-radius: 100px 0 0 100px/100px 0 0 100px;
  }

  .percentCircleLeft .leftContent {
    position: absolute;
    content: '';
    width: 100%;
    height: 100%;
    transform-origin:right center;
    transform: rotate(0deg);
    border-radius: 100px 0 0 100px/100px 0 0 100px;
    background:#F9C975;
  }

  .textCircle {
    position: absolute;
    display:flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height:80%;
    width:80%;
    left:10%;
    top:10%;
    border-radius:100%;
    background:#ffffff;
  }

在这里插入图片描述
原理是两个半圆 底部放了一个圆
transform-origin:right center; 通过这个属性 决定圆环的旋转的圆心
transform: rotate(0deg); 旋转的角度
border-radius: 100px 0 0 100px/100px 0 0 100px; 圆角

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值