【微信小程序】checkbox,radio的样式修改

一、checkbox样式修改

默认勾选与未勾选样式
在这里插入图片描述在这里插入图片描述

wxml

 <checkbox color="#fff" value="{{id}}" checked="{{checked}}"></checkbox>

设置wxss文件
更改大小、勾选背景颜色等:
在这里插入图片描述

// 未勾选样式
.wx-checkbox-input {
  width: 33rpx !important;
  height: 33rpx !important;
}
//环形的外圈
radio .wx-radio-input.wx-radio-input-checked {
  border: 2rpx solid #00bcd4 !important;
}
//选中后背景及勾的样式
radio .wx-radio-input.wx-radio-input-checked::before {
  border-radius: 50%;
  width: 20rpx;
  height: 20rpx;
  line-height: 20rpx;
  text-align: center;
  font-size: 0;
  background: #00bcd4;
  transform: translate(-50%, -50%) scale(1);
}

修改radio的样式为环形
在这里插入图片描述

// 未勾选样式
.wx-checkbox-input {
  width: 33rpx !important;
  height: 33rpx !important;
}
// 勾选样式
.wx-checkbox-input.wx-checkbox-input-checked{
  border-color:#00BCD4 !important;
  background:#00BCD4 !important;
}
二、radio样式修改

wxml中的color要给一个值

<radio value="0" bindtap="radioChange" checked="{{check}}" color="#fff"></radio>

设置wxss文件

// 未勾选样式
.wx-radio-input {
  width: 32rpx !important;
  height: 32rpx !important;
  border-radius: 100%;
  background-color: #fff !important;
}
// 勾选样式
.wx-radio-input.wx-radio-input-checked {
  width: 32rpx !important;
  height: 32rpx !important;
  background-color: #00bcd4 !important;
}
  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值