Is it posible to make an input checkbox a Bootstrap glyphicon?

后端 未结 3 1034
一整个雨季
一整个雨季 2020-12-18 16:11

Is it posible to make an input checkbox a Bootstrap glyphicon?

I want to make up the default checkboxes with a nice Bootstrap glyphicon. For example: glyphicon

3条回答
  •  攒了一身酷
    2020-12-18 16:39

    if you have the icons, you can style it as such: http://jsfiddle.net/swm53ran/164/

    /*hide checkbox and radio buttons*/
    input[type=checkbox], 
    input[type=radio] {
        width: 2em;
        margin: 0;
        padding: 0;
        font-size: 1em;
        opacity: 0; /*This is the part tht actually hides it*/
    }
    
    /*normalize the spacing*/
    input[type=checkbox] + label,
    input[type=radio] + label {
        display: inline-block;
        margin-left: -2em;
        line-height: 1.5em;
    }
    
    /*unchecked css*/
    input[type=checkbox] + label > span,
    input[type=radio] + label > span {
        display: inline-block;
        background-image: url('http://upload.wikimedia.org/wikipedia/commons/thumb/0/06/Face-sad.svg/48px-Face-sad.svg.png');
        width: 50px;
        height: 50px;
    }
    
    /*selected checkbox css*/
    input[type=checkbox]:checked + label > span > span {
        width: 50px;
        height: 50px;
        display:block;
        background-image: url('http://wscont1.apps.microsoft.com/winstore/1x/a14c3995-34d7-454c-82e2-0c192e48b91a/Icon.173718.png');
    }
    
    /*selected radio css*/
    input[type=radio]:checked + label > span > span {
        width: 50px;
        height: 50px;
        display:block;
        background-image: url('http://wscont1.apps.microsoft.com/winstore/1x/a14c3995-34d7-454c-82e2-0c192e48b91a/Icon.173718.png');
    }
    
    

提交回复
热议问题