H5:border-radius移动端的兼容问题

问题场景

通过以下方式实现一个圆形边框的选项值

.option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    text-align: center;
    line-height: 40px;
    font-size: 36px;
    color: #888888;
    border: 2px solid #888888;
}

在chrome和其他浏览器上一直显示正常。在个别移动端机子上,出现圆圈不圆和文字不居中的情况。

 

原因

移动端有些机子对border-radius百分比支持属性存在兼容问题。

 

解决方案

不使用百分比,使用固定值,同时加一下前缀 -webkit-、-moz-

.option {
    width: 40px;
    height: 40px;
    border-radius: 20px;
    -webkit-border-radius:20px;
    -moz-border-radius:20px;
    text-align: center;
    line-height: 40px;
    font-size: 36px;
    color: #888888;
    border: 2px solid #888888;
}

亲测有效

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据提供的引用,uniapp的进度条border-radius可以通过以下两种方法来实现。 第一种方法是针对原生app项目,在代码中通过设置样式类名来控制进度条的border-radius。具体代码如下: ``` <view class="progressBoxCon"> <view class="progressBox" ref="progressBox"> <view class="progressItem" v-for="(item,index) in progressBox" :key="index"> <view>{{item.province}}</view> <progress class="progress" :num="item.number" :percent="item.percent" :activeColor="item.activeColor" active stroke-width="19" backgroundColor="none"/> <view>{{item.ratio}}%</view> </view> </view> </view> <style lang="scss"> .progress { border-radius: 10px; /* 这里设置border-radius的值 */ } .progress::after { content: attr(num); margin-right: 30upx; font-size: 22upx; color: #FFFFFF; position: absolute; margin-left: 25upx; } </style> ``` 第二种方法适用于H5项目,可以通过添加一些额外的代码来实现进度条的border-radius。具体代码如下: ``` mounted() { const list = Array.from(this.$refs.progressBox.$el.getElementsByClassName('uni-progress-inner-bar')); list.forEach((item,index)=>{ item.setAttribute("num",this.progressBox[index].number); }); } <style scoped> .progressBox /deep/ .uni-progress-inner-bar::after { content: attr(num); } .uni-progress-inner-bar { border-radius: 10px; /* 这里设置border-radius的值 */ } </style> ``` 通过以上两种方法,你可以在uniapp中设置进度条的border-radius属性。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [uniapp的progress进度条组件添加文字](https://blog.csdn.net/document_write/article/details/110704512)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *3* [react-progress-bar:简单的React进度栏组件](https://download.csdn.net/download/weixin_42135753/18211426)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

KWMax

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值