修改 input checkbox(复选框) 默认的背景颜色

修改 input checkbox(复选框) 默认的背景颜色

附上代码:

通过 after 伪类选择器 实现

input[type=checkbox]{
     cursor: pointer;
     position: relative;
     width: 15px;
     height: 15px;
     font-size: 14px;
}

input[type=checkbox]::after{
     position: absolute;
     top: 0;
     background-color: red;
     color: #000;
     width: 15px;
     height: 15px;
     display: inline-block;
     visibility: visible;
     text-align: center;
     content: ' ';
}
        
input[type=checkbox]:checked::after{
     content: "✓";
     font-size: 12px;
     font-weight: bold;
}

你可能感兴趣的:(html,css,html,checkbox)