Custom checkbox using font awesome and css

前端 未结 2 1844
夕颜
夕颜 2021-01-26 13:21

I\'m making a custom checkbox with font awesome and css.

On click/when checkbox is checked, I trying to create some padding around the black checked box instead(having a

2条回答
  •  再見小時候
    2021-01-26 13:43

    You're using a single character so you can't add letter-spacing.

    I'd suggest something like this.

    Reduce the size of the replacement icon/character, add padding and a border. Alternatively, search for a proper icon/character that appears how you want it to be and use that.

    @import url(//netdna.bootstrapcdn.com/font-awesome/3.2.1/css/font-awesome.css);
    
    /*** basic styles ***/
    
    /*** custom checkboxes ***/
    
    input[type=checkbox] {
      display: none;
    }
    /* to hide the checkbox itself */
    
    input[type=checkbox] + label:before {
      font-family: FontAwesome;
    }
    input[type=checkbox] + label:before {
      content: "\f096";
    }
    /* unchecked icon */
    
    /*input[type=checkbox] + label:before { letter-spacing: 10px; }*/
    
    /* space between checkbox and label */
    
    input[type=checkbox]:checked + label:before {
      content: "\f0c8";
      display: inline-block;
    }
    /* checked icon */
    
    input[type=checkbox]:checked + label:before {
      font-size: 60%;
      border: 1px solid black;
      vertical-align: top;
      padding: 2px;
      border-radius: 2px;
    }
    /* allow space for check mark */


提交回复
热议问题