自定义复选框样式

<label><input type="checkbox"><b class="checkbodB"></b>选我</label>
/*样式*/
input[type="checkbox"] {
    display: none;
}

input[type="checkbox"]+b.checkbodB {
    display: inline-block;
    width: 15px;
    height: 15px;
    margin-top: -1px;
    border: 1px solid #ccc;
    cursor: pointer;
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border-radius: 2px;
    vertical-align: middle;
    position: relative;
    margin-right: 10px;
    background-color: #ffffff;
}

input[type="checkbox"]+b.checkbodB:after {
    content: " ";
    display: inline-block;
    position: absolute;
    width: 9px;
    height: 5px;
    top: 3px;
    left: 2px;
    border: 2px solid #3399ff;
    cursor: pointer;
    border-top: none;
    border-right: none;
    background: transparent;
    filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
    opacity: 0;
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);
}

input[type="checkbox"]:checked+b.checkbodB:after {
    /*background: #f00;
    border-color: #f00;*/
    opacity: 1;
}
/*结果*/



<label><input type="checkbox"><b>标记1</b></label><label><input type="checkbox"><b>标记2</b></label><label><input type="checkbox"><b>标记3</b></label>
/*样式*/
input[type="checkbox"] {
    display: none;
}
input[type="checkbox"]+b {
    display: inline-block;
    /*width: 74px;*/
    padding: 0 20px;
    border: 1px solid #ddd;
    cursor: pointer;
    vertical-align: middle;
    position: relative;
    text-align: center;
    line-height: 30px;
    font-weight: 400;
    font-size:12px;
    color:#666666;
    margin-right:20px;
}

 input[type="checkbox"]:checked+b {
    border: 2px solid #3399ff;
}

 input[type="checkbox"]:checked+b:before {
    content: " ";
    display: inline-block;
    width: 0;
    height: 0;
    bottom: 0px;
    right: 0px;
    position: absolute;
    border-bottom: 15px solid #3399FF;
    border-left: 15px solid transparent;
}

input[type="checkbox"]+b:after {
    content: " ";
    display: inline-block;
    position: absolute;
    width: 6px;
    height: 3px;
    bottom: 3px;
    right: 2px;
    border: 1px solid #FFFFFF;
    cursor: pointer;
    border-top: none;
    border-right: none;
    background: transparent;
    filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0);
    opacity: 0;
    -moz-transform: rotate(-45deg);
    -ms-transform: rotate(-45deg);
    -webkit-transform: rotate(-45deg);
    transform: rotate(-45deg);
}

 input[type="checkbox"]:checked+b:after {
    opacity: 1;
}
/*结果*/



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值