CSS 自定义Radio样式

效果图

 

 

 

 

 

HTML代码

<table>
            <tr>
                <td style="font-weight: bold;">检查事项</td>
                <td style="text-align: center;width: 40px;">
                    <img style="width: 20px;" src="../../image/handover/y.png"/>
                </td>
                <td style="text-align: center;width: 40px;">
                    <img style="width: 20px;"  src="../../image/handover/x.png"/>
                </td>
            </tr>
            <tr>
                <td>非雷雨天气</td>
                <td style="text-align: center;width: 40px;">
                    <input type="radio" name="item1" id="item1_yes"/><label for="item1_yes"></label>
                </td>
                <td style="text-align: center;width: 40px;">
                    <input type="radio" name="item1" id="item1_no"/><label for="item1_no"></label>
                </td>
            </tr>
            <tr>
                <td>只会车辆停泊到位</td>
                <td style="text-align: center;width: 40px;">
                    <input type="radio" name="item2" id="item2_yes"/><label for="item2_yes"></label>
                </td>
                <td style="text-align: center;width: 40px;">
                    <input type="radio" name="item2" id="item2_no"/><label for="item2_no"></label>
                </td>
            </tr>
            <tr>
                <td>其他选项...</td>
                <td style="text-align: center;width: 40px;">
                    <input type="radio" name="item3" id="item3_yes"/><label for="item3_yes"></label>
                </td>
                <td style="text-align: center;width: 40px;">
                    <input type="radio" name="item3" id="item3_no"/><label for="item3_no"></label>
                </td>
            </tr>
        </table>

CSS代码

input[type="radio"] + label::before {
    content: " ";
    display: inline-block;
    vertical-align: middle;
    width: 20px;
    height:  20px;
    border-radius: 30%;
    border: solid 1px #1259B7;
    margin-right: .213333rem;
    box-sizing: border-box;
	position: relative;
	top: -2px;
}
input[type="radio"]:checked + label::before {
    background-color: #30F546;
    background-clip: content-box;
    padding: 0px;
    box-sizing: border-box;
}
input[type="radio"] {
    position: absolute;
    clip: rect(0, 0, 0, 0);
}
input[id$="no"]:checked + label::before {
    background-color:#F76167;
    background-clip: content-box;
    padding: 0px;
    box-sizing: border-box;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值