修改小程式radio的樣式
阿新 • • 發佈:2020-09-17
效果圖
程式碼
html部分
<radio-group bindchange="radioChange" name="sex"> <label class="" wx:for="{{sex}}" wx:key="{{item.value}}" style="margin-right:40rpx;"> <radio value="{{item.value}}" checked="true"/>{{item.text}} </label> </radio-group>
css部分
radio .wx-radio-input.wx-radio-input-checked { border-color: #cc0000; background: #cc0000; } radio .wx-radio-input { height: 35rpx; width: 35rpx; margin-top: -4rpx; border-radius: 50%; border: 2rpx solid #999; background: transparent; } radio .wx-radio-input.wx-radio-input-checked::before { border-radius: 50%; /* 圓角 */ width: 35rpx; /* 選中後對勾大小,不要超過背景的尺寸 */ height: 35rpx; /* 選中後對勾大小,不要超過背景的尺寸 */ line-height: 35rpx; text-align: center; font-size: 28rpx; /* 對勾大小 30rpx */ color: #fff; /* 對勾顏色 白色 */ background: #cc0000; transform: translate(-50%, -50%) scale(1); -webkit-transform: translate(-50%, -50%) scale(1); }
js 部分
Page({
data: {
sex:[
{text:'男',value:1},
{text:'女',value:2},
]
}
})