0
I’m trying to leave the checkbox this way:
But I’m not getting to leave the gray background as a pattern, and only when it’s marked will it be blue.
Follow my code:
input[type=checkbox] {
position: relative;
cursor: pointer;
}
input[type=checkbox]:before {
content: "";
display: block;
position: absolute;
width: 25px;
height: 25px;
top: 0;
left: 0;
background-color: #2196F3;
}
input[type=checkbox]:checked:after {
content: "";
display: block;
width: 5px;
height: 10px;
border: solid white;
border-width: 0 3px 3px 0;
-webkit-transform: rotate(45deg);
-ms-transform: rotate(45deg);
transform: rotate(45deg);
position: absolute;
top: 5px;
left: 9px;
}
span{
margin: 0px 15px;
}
<p> <input type="checkbox"> <span>Um</span> </p>
<p> <input type="checkbox"> <span>Dois</span> </p>
<p> <input type="checkbox"> <span>Tres</span> </p>
<p> <input type="checkbox"> <span>Quatro</span> </p>
I do,put blue in the checkbox marked and unchecked with gray variation. The problem that in V8 has a bug which does not correctly insert complex selectors into the pseudo-class
:nth-of-type()
which you would use to generate a lighter gray tone for each checkbox. It means I answer the question but the code is not automatic, if you add one morecheckbox
you’ll have to rewrite the CSS for this checkbox.– Augusto Vasques