uniapp 单选框以及多选框样式更改

radio以及checkbox默认样式不符合自身需求时,根据自身需求更改样式,以下是自身的示例:

单选:

多选:

由于uniapp自身包含了一套默认的样式,所以如果不想全局更改只想在某个单据页面使用的话,就要考虑CSS优先级的问题,以下为具体样式,给大家做一个参考:(我这边可能会麻烦一点,大家按照自身需求删减哈)

单选框CSS:

复制代码
/* radio 边框颜色 */
/deep/ uni-radio .uni-radio-input{
    width: 30rpx;
    height: 30rpx;
    border:2rpx solid rgba(166, 175, 255, 0.5)!important;
    transform: rotateZ(360deg);  //防止IOS出现一侧边框缺失的问题
    background-color: rgba(255, 255, 255, 0)!important;
    margin-right:0rpx!important;  //uniapp 默认右侧会有一定的margin,大家根据自身需求去除
}

/* radio 选中后的边框颜色 */
/deep/ uni-radio .uni-radio-input-checked {
    border:2rpx solid #CACFFF!important;
    transform: rotateZ(360deg);
    background-color: #556FFE!important;
    display:flex;
    align-items: center;
    justify-content: center;
}

/* radio 选中后的图标样式*/
/deep/  uni-radio .uni-radio-input.uni-radio-input-checked::before{
     display: block;
     content: ""!important;
      width:20rpx!important;
      height:20rpx!important;
      text-align:center;
       background:#fff!important;
      border-radius:20rpx!important;
 }

多选框CSS:

复制代码
/deep/ uni-checkbox .uni-checkbox-input{
    width: 30rpx;
    height: 30rpx;
    border-radius: 8rpx;
    border: 2rpx solid #5262E8;
    transform: rotateZ(360deg);
    background-color: rgba(255, 255, 255, 0)!important;
    pointer-events: none;
}

/deep/ uni-checkbox .uni-checkbox-input-checked{
    border:2rpx solid #CACFFF!important;
    transform: rotateZ(360deg);
    background-color: #556FFE!important;
}

/deep/ uni-checkbox .uni-checkbox-input-checked::before{
     font-size: 12px!important;
     font-weight:bold;
     color:#fff;
}
相关推荐
weixin_3947580326 分钟前
CRMEB Pro 商品字段二开:为什么加一个字段会牵动 SKU、缓存和前端展示?
前端·缓存
IT_陈寒32 分钟前
Python的pickle让我半夜加班,这破玩意儿太坑了
前端·人工智能·后端
qq_422152571 小时前
图片格式转换工具怎么选?JPEG、PNG、WebP、AVIF 格式对比与在线转换方案实测
前端
xiaofeichaichai1 小时前
ES 新特性九年速览:从 ES2016 到 ES2024
前端·javascript·es6
2401_834636991 小时前
Keepalived + LVS (DR) + Nginx + NFS 高可用 Web 集群部署实战手册
前端·nginx·lvs
和你看星星1 小时前
我把代码排查流程做成了一个 Codex Skill
前端
excel1 小时前
AI 冲击下的前端发展指引:从工具到价值的重塑
前端
文心快码BaiduComate1 小时前
提升组织级AI Coding质量:电商搜索项目实践
前端·后端·程序员
excel2 小时前
AI 时代前端转型:模型训练才是未来的核心竞争力
前端
放下华子我只抽RuiKe52 小时前
FastAPI 全栈后端(四):认证与授权
开发语言·前端·javascript·python·深度学习·react.js·fastapi