单选多选样式写法

动画多选样式

// html
<div id="box">
    <input type="checkbox" id="check" name="check" />
    <label for="check">Checkbox</label>
</div>

// css
input[type=checkbox]+label:before {
    height: 16px;
    line-height: 16px;
    width: 16px;
    border: 1px solid #000;
    display: inline-block;
    vertical-align: top;
    text-align: center;
    margin-right: 5px;
    content: "\2713";
    color: transparent;
    transition: color ease .3s;
}
input[type=checkbox]:checked+label:before {
    color: #000;
}

单选按钮样式

// html
<div id="box">
    <input type="radio" id="check" name="check" />
    <label for="check">Checkbox</label>
</div>
// css
input[type=radio] {
    display: none;
}
input[type=radio]+label:before {
    display: inline-block;
    width: 16px;
    height: 16px;
    line-height: 14px;
    text-align: center;
    vertical-align: top;
    margin-right: 20px;
    content: "\26AB";
    border: 1px solid #000;
    border-radius: 50%;
    font-size: 0;
    transition: font-size ease .3s;
}
input[type=radio]:checked+label:before {
    font-size: 12px;
}

参考

掘金-22个必备的CSS小技巧

转载于:https://www.cnblogs.com/bonly-ge/p/10118106.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值