自定义单选框,复选框样式

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        input{width: 0;height: 0;position: absolute;left: -9999em}
        *{margin: 0;padding: 0}
        label{position: relative;height: 25px;display: block;}
        input[type="radio"] + label::before {
            content: "\a0"; /*不换行空格*/
            display: inline-block;
            width: 18px;
            height: 18px;
            margin-right: 5px;
            border-radius: 50%;
            border: 1px solid #01cd78;
            text-indent: 5px;
        }
        input[type="radio"] + label::after {
            content: "\a0"; /*不换行空格*/
            display: inline-block;
            width: 10px;
            height: 10px;
            margin-right: 5px;
            border-radius: 50%;
            background: #01cd78;
            position: absolute;
            left: 5px;
            top: 5px;
            opacity: 0;

        }

        input[type="radio"]:checked + label::after {
            opacity:1;
        }


        input[type="checkbox"] + label::before {
            content: "\a0"; /*不换行空格*/
            display: inline-block;
            width: 18px;
            height: 18px;
            margin-right: 5px;
            border: 1px solid #01cd78;
            text-indent: 5px;
        }
        input[type="checkbox"] + label::after {
            content: "\a0"; /*不换行空格*/
            display: inline-block;
            width: 10px;
            height: 10px;
            margin-right: 5px;
            background: #01cd78;
            position: absolute;
            left: 5px;
            top: 5px;
            opacity: 0;

        }

        input[type="checkbox"]:checked + label::after {
            opacity:1;
        }
        i{font-style: normal}


    </style>
</head>
<body>
<div class="female">
    <input type="radio" id="female" name="sex" checked/>
    <label for="female"><i></i></label>
</div>
<div class="male">
    <input type="radio" id="male" name="sex" />
    <label for="male"><i></i></label>
</div>


<div class="female">
    <input type="checkbox" id="female2" name="sex" checked/>
    <label for="female2"><i></i></label>
</div>
<div class="male">
    <input type="checkbox" id="male2" name="sex" />
    <label for="male2"><i>熊掌</i></label>
</div>

</body>
</html>

 

转载于:https://www.cnblogs.com/xiaobaibubai/p/7992712.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值