我正在尝试将未选中的复选框的背景颜色设置为白色,但我找不到方法来做到这一点。当选中和未选中时,它都会保持蓝色。我尝试过:
input[type=checkbox]:not(:checked) {
background-color: white;
}
Run Code Online (Sandbox Code Playgroud)
并且:
input[type=checkbox]:after { (this one I don't think it's even valid)
background-color: white;
}
Run Code Online (Sandbox Code Playgroud)
我目前的代码是:
input[type=checkbox]:not(:checked) {
background-color: white;
}
Run Code Online (Sandbox Code Playgroud)
input[type=checkbox]:after { (this one I don't think it's even valid)
background-color: white;
}
Run Code Online (Sandbox Code Playgroud)
如果有人有任何想法,我将不胜感激。谢谢
这是基于您的代码的示例解决方案:
input[type=checkbox] {
position: relative;
cursor: pointer;
}
input[type=checkbox]:before {
content: "";
position: absolute;
width: 16px;
height: 16px;
top: 0;
left: 0;
border: 1px solid #99AFC1;
border-radius: 3px;
padding: 1px;
background-color: #FFFFFF;
}
input[type=checkbox]:checked:before {
background-color: #00AEEF;
}
input[type=checkbox]:checked:after {
content: "";
display: block;
width: 5px;
height: 10px;
border: solid white;
border-width: 0 2px 2px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
top: 2px;
left: 6px;
}Run Code Online (Sandbox Code Playgroud)
<div class="container">
<input type="checkbox" name="test">
</div>Run Code Online (Sandbox Code Playgroud)