How to style a checkbox using CSS

前端 未结 30 3526
日久生厌
日久生厌 2020-11-21 04:26

I am trying to style a checkbox using the following:

30条回答
  •  遥遥无期
    2020-11-21 05:20

    Here is a simple CSS solution without any jQuery or JavaScript code.

    I am using FontAwseome icons but you can use any image

    input[type=checkbox] {
      display: inline-block;
      font-family: FontAwesome;
      font-style: normal;
      font-weight: normal;
      line-height: 1;
      -webkit-font-smoothing: antialiased;
      -moz-osx-font-smoothing: grayscale;
      visibility: hidden;
      font-size: 14px;
    }
    
    input[type=checkbox]:before {
      content: @fa-var-square-o;
      visibility: visible;
      /*font-size: 12px;*/
    }
    
    input[type=checkbox]:checked:before {
      content: @fa-var-check-square-o;
    }
    

提交回复
热议问题