How to style a checkbox using CSS

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

I am trying to style a checkbox using the following:

30条回答
  •  你的背包
    2020-11-21 05:23

    You can avoid adding extra markup. This works everywhere except IE for Desktop (but works in IE for Windows Phone and Microsoft Edge) via setting CSS appearance:

    input[type="checkbox"] {
      -webkit-appearance: none;
      -moz-appearance: none;
      appearance: none;
    
      /* Styling checkbox */
      width: 16px;
      height: 16px;
      background-color: red;
    }
    
    input[type="checkbox"]:checked {
      background-color: green;
    }

提交回复
热议问题