CSS/HTML: How do I change the color of the check mark within the checkbox input?

前端 未结 5 1995
甜味超标
甜味超标 2020-12-01 16:23

How do I change the color of the check mark within an HTML checkbox input?

5条回答
  •  孤城傲影
    2020-12-01 16:40

    You can imitate a check box with another element and set the background color as desired.

    
    
    

    You can get a little fancier by using ::before or after

    
    
    

    You can extend this, by using background image or a svg sprite in the ::after tag (see https://stackoverflow.com/a/19255455/87520)

    I haven't tried to make it perfect, just to demonstrate the concept. As you can see, the background color is green, no images, no libraries involved; minimal js.

提交回复
热议问题