CSS改变checkbox样式

    xiaoxiao2021-03-25  106

    CSS改变checkbox样式,代码如下:

    Html代码

     

    <div class="hv_box"> <input type="checkbox" class="hc_checkbox" id="ck1" value="1322560"/> <lable for="ck1"></lable> </div>

     

    注意:id的值随意,但是要和lable中for值一样,不然找不到

    多个选择框时,id可以使用不同的值,但是要和lable中for值一样

     

     

    CSS

        .hc_box{width: 18px;height: 90px;float: left;position: relative;margin-right: 10px;}hc_box{width: 18px;height: 90px;float: left;position: relative;margin-right: 10px;} .hc_checkbox{position: absolute;width: 18px;height: 18px;visibility: hidden;top: 0px;} .hc_checkbox+label {display: inline-block;width: 18px;height: 18px;background:url(../img/check_icon.png) no-repeat;background-position: -18px 0px;margin-top: 0px;} .hc_checkbox:checked+label {background-position: 0px 0px;}  

     

    选择框图片

    效果预览

    转载请注明原文地址: https://ju.6miu.com/read-23534.html

    最新回复(0)