复选框

<div class="icon-check">
    <input class="c1" type="checkbox" name="" id="input-check" value="" />
    <label for="input-check">复选框</label>
</div>
.icon-check{
    display: inline-block;
}
.icon-check .c1{
    /*display: none;*//*注意,此处不能用display:none,我们应该把原来的复选框以一种不损失访问性的方式隐藏起来,使用display:none,会把它从键盘tab键切换焦点的队列中完全删除*/
    position:absolute;
    clip:rect(0,0,0,0);
}
.icon-check label{
    position: relative;
    display: block;
    font-size: 14px;
    padding-left: 24px;
}
.icon-check label:before{
    position: absolute;
    top: 50%;
    left: 0;
    content: '';
    width: 20px;
    height: 20px;
    border: 1px solid #FF0000;
    border-radius: 3px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    margin-top: -10px;
}
.icon-check .c1 + label:after{
    position: absolute;
    top: 50%;
    left: 0;
    content: '';
    width: 20px;
    height: 20px;
    border: 1px solid #FF0000;
    background:#FF0000 url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAElSURBVFhH7ZbhDYIwEIUZgREYgREYwRHcQEdwBEdwA9wANtANdAOYgPpe0ppyqYQ/lDO5Jk1swdzH1/JKUVgzA2bADJgBMxAMOOcuvpfqrACsQQ9tJKgqyGmanhGgw/iqBhBgRwE3YKxjmQmCziX9Ntg7a7LHFyOGe2mCq2I4/7tRA4ilvAt7nRo4ESuBs1IDKGNFVe7xLf2rWGEObr60KFL7c7ReKsYTQth75IArxZ5KnqMA2ydWUPiWyLOeQLEdjDkXh3K7uT0WQMUDDA4JyDEcWzJW/P35YgUAXOY2AcmpHtfe4to+n1MLNmfnLR8oy/KminDvwVj3wyant4+VNU8PyJPcmwRf899s9yRs6vlaiS3QJoM8mxkrZAbMgBkwAzoMfAB0fkWZj4GYcAAAAABJRU5ErkJggg==") no-repeat center;
    background-size: 100%;
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
    border-radius: 3px;
    -moz-border-radius: 3px;
    -webkit-border-radius: 3px;
    margin-top: -10px;
    opacity: 0;
    -moz-opacity: 0;
    -webkit-opacity: 0;
}
.icon-check .c1:checked + label:after{
    opacity: 1;
    -moz-opacity: 1;
    -webkit-opacity: 1;
}

效果:
这里写图片描述
这里写图片描述


2018年8月2日更新:

.icon-check .c1{
    /*display: none;*//*注意,此处不能用display:none,我们应该把原来的复选框以一种不损失访问性的方式隐藏起来,使用display:none,会把它从键盘tab键切换焦点的队列中完全删除*/
    position:absolute;
    clip:rect(0,0,0,0);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值