微信小程序中,选项的默认样式是一个对勾,非常丑,虽然可以更改选中时图片的路径,但是不用图片, 用样式也是非常好看的,效果如下:
![](https://img.haomeiwen.com/i4321660/4a0bbd945c693ad8.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);
}
网友评论