/* 重寫 checkbox 樣式 */ /* 未選中的 背景樣式 */ checkbox .wx-checkbox-input{ border-radius: 50%;/* 圓角 */ width: 40rpx; /* 背景的寬 */ height: 40rpx; /* 背景的高 */ } /* 這里如果不能修改背景顏色,在選中后的樣式中添加background-color */ /* 選中后的 背景樣式 (紅色背景 無邊框 可根據UI需求自己修改) */ checkbox .wx-checkbox-input.wx-checkbox-input-checked{ border: none; background: red; } /* 選中后的 對勾樣式 (白色對勾 可根據UI需求自己修改) */ checkbox .wx-checkbox-input.wx-checkbox-input-checked::before{ border-radius: 50%;/* 圓角 */ width: 40rpx;/* 選中后對勾大小,不要超過背景的尺寸 */ height: 40rpx;/* 選中后對勾大小,不要超過背景的尺寸 */ line-height: 40rpx; text-align: center; font-size:30rpx; /* 對勾大小 30rpx */ color:#fff; /* 對勾顏色 白色 */ background: transparent; transform:translate(-50%, -50%) scale(1); -webkit-transform:translate(-50%, -50%) scale(1); }
/* 重寫 radio 樣式 */ /* 未選中的 背景樣式 */ radio .wx-radio-input{ border-radius: 50%;/* 圓角 */ width: 40rpx; height: 40rpx; } /* 這里如果不能修改背景顏色,在選中后的樣式中添加background-color */ /* 選中后的 背景樣式 (紅色背景 無邊框 可根據UI需求自己修改) */ radio .wx-radio-input.wx-radio-input-checked{ border: none; background: red; } /* 選中后的 對勾樣式 (白色對勾 可根據UI需求自己修改) */ radio .wx-radio-input.wx-radio-input-checked::before{ border-radius: 50%;/* 圓角 */ width: 40rpx; /* 選中后對勾大小,不要超過背景的尺寸 */ height: 40rpx; /* 選中后對勾大小,不要超過背景的尺寸 */ line-height: 40rpx; text-align: center; font-size:30rpx; /* 對勾大小 30rpx */ color:#fff; /* 對勾顏色 白色 */ background: transparent; transform:translate(-50%, -50%) scale(1); -webkit-transform:translate(-50%, -50%) scale(1); }
參考地址 :https://blog.csdn.net/weixin_41327977/article/details/89956942