美文网首页
微信小程序更改radio/checkbox 单选/多选默认样式

微信小程序更改radio/checkbox 单选/多选默认样式

作者: 虚幻的锈色 | 来源:发表于2019-11-18 17:51 被阅读0次

微信小程序中,选项的默认样式是一个对勾,非常丑,虽然可以更改选中时图片的路径,但是不用图片, 用样式也是非常好看的,效果如下:

image.png

没啥可说的, 直接上代码,复制粘贴,放到 app.wxss中既可。 非常简单。

更改小程序中 单选框、多选框的默认样式:


/*更改全局 radio样式*/
radio .wx-radio-input {
  border-radius: 50%;
  width: 28rpx;
  height: 28rpx;
  border: 2rpx solid #9fa7a9;
}
/* 选中后的 样式 */
radio .wx-radio-input.wx-radio-input-checked {
  border-color: #2792ff !important;
}
/* 选中后的 对勾样式 */
radio .wx-radio-input.wx-radio-input-checked::before {
  /* 去除对号 */
  content: '';
  font-size: 0rpx; 
  border-radius: 50%;
  width: 70%;
  height: 70%;
  text-align: center;
  background-color: #2792ff;
  transform: translate(-50%, -50%) scale(1);
  -webkit-transform: translate(-50%, -50%) scale(1);
}


/*checkbox未选中时样式 */
checkbox .wx-checkbox-input {
  /* border-radius: 50%; */
  width: 28rpx;
  height: 28rpx;
  border: 2rpx solid #9fa7a9;
}
/* 选中后的 样式  */
checkbox .wx-checkbox-input.wx-checkbox-input-checked {
  /* border-radius: 50%; */
  border-color: #2792ff !important;
}
/* 选中后的 对勾样式 */
checkbox .wx-checkbox-input.wx-checkbox-input-checked::before {
  /* border-radius: 50%; */
  /* 去除对号 */
  content: '';
  font-size: 0rpx;
  text-align: center;
  width: 70%;
  height: 70%;
  background-color: #2792ff;
  transform: translate(-50%, -50%) scale(1);
  -webkit-transform: translate(-50%, -50%) scale(1);
}

相关文章

网友评论

      本文标题:微信小程序更改radio/checkbox 单选/多选默认样式

      本文链接:https://www.haomeiwen.com/subject/cwvbictx.html