小程序修改checkbox,radio组件样式

标签给加一个checkbox类:

<checkbox  class="checkbox"  checked="true"/>
复制代码

样式:web

.checkbox .wx-checkbox-input {
  border-radius: 32rpx; /* 圆角 */
  width: 32rpx; /* 背景的宽 */
  height: 32rpx; /* 背景的高 */
  border: 2px solid #50ab38;
}
.checkbox .wx-checkbox-input-disabled {
  border-radius: 32rpx; /* 圆角 */
  width: 32rpx; /* 背景的宽 */
  height: 32rpx; /* 背景的高 */
  background: #f3f3f3;
  border: 1px solid rgba(201, 201, 201, 1);
}
.checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  background: #50ab38;
}
.checkbox  .wx-checkbox-input.wx-checkbox-input-checked::before {
  width: 32rpx;
  height: 32rpx;
  line-height: 32rpx;
  text-align: center;
  font-size: 24rpx;
  color: #fff;
  background: transparent;
  transform: translate(-50%, -50%) scale(1);
  -webkit-transform: translate(-50%, -50%) scale(1);
}



复制代码

标签给加一个radio类:bash

<radio class="radio">点我</radio>
复制代码

样式:spa

/* 自定义样式.... */
radio .wx-radio-input{ 
    height: 30rpx; 
    width: 30rpx;
    margin-right: -4rpx;
    margin-top: -3rpx;
    border-radius: 50%;
    border: 2rpx solid #999;
    background: transparent;
}

 
/* 选中后的 对勾样式 (白色对勾 可根据UI需求本身修改)  */
radio .wx-radio-input.wx-radio-input-checked::before{
   border-radius: 50%;/* 圆角 */
   width: 20rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
   height: 20rpx; /* 选中后对勾大小,不要超过背景的尺寸 */
   line-height: 20rpx;
   text-align: center;
   font-size:20rpx; /* 对勾大小 30rpx */
   color:#fff; /* 对勾颜色 白色 */
   background: #f00;
   transform:translate(-50%, -50%) scale(1);
   -webkit-transform:translate(-50%, -50%) scale(1);
}

/* 选中后的 背景样式 (红色背景 无边框 可根据UI需求本身修改) */
radio .wx-radio-input.wx-radio-input-checked{
   border: none;
   background: red;
}
复制代码
相关文章
相关标签/搜索