How to style a checkbox using CSS

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

I am trying to style a checkbox using the following:

30条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-21 05:02

    A simple and lightweight template as well:

    input[type=checkbox] {
      cursor: pointer;
    }
    
    input[type=checkbox]:checked:before {
      content: "\2713";
      background: #fffed5;
      text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
      font-size: 20px;
      text-align: center;
      line-height: 8px;
      display: inline-block;
      width: 13px;
      height: 15px;
      color: #00904f;
      border: 1px solid #cdcdcd;
      border-radius: 4px;
      margin: -3px -3px;
      text-indent: 1px;
    }
    
    input[type=checkbox]:before {
      content: "\202A";
      background: #ffffff;
      text-shadow: 1px 1px 1px rgba(0, 0, 0, .2);
      font-size: 20px;
      text-align: center;
      line-height: 8px;
      display: inline-block;
      width: 13px;
      height: 15px;
      color: #00904f;
      border: 1px solid #cdcdcd;
      border-radius: 4px;
      margin: -3px -3px;
      text-indent: 1px;
    }
    checked1
    unchecked2


    https://jsfiddle.net/rvgccn5b/

提交回复
热议问题