Struggling to create custom styling for a checkbox due to the limitations of input type="checkbox"
.
Check out my attempt at using CSS to style a checkbox:
label > input[type="checkbox"] + span::before {
content: "✓";
width: 20pt;
height: 20pt;
border-radius: 10%;
border-style: solid;
border-width: 0.1rem;
border-color: gray;
display: inline-block;
vertical-align: middle;
}
<label>
<input type="checkbox" name="pos[]" value="shirt" />
<span> shirt </span>
<br>
</label>
Desired behavior includes:
- Empty square centered vertically
- Checkmark inside the square
The square is centered, but the checkmark "✓" appears at the bottom, aligned with text next to it. Various attempts with display
and vertical-align
have not been successful. How can I center the checkmark properly?