I've made a form with a checkbox. Now I need to make a checkbox appear as on the image:
What would be the best way to achieve this?
Also, they checkbox should be :checked
once the label is clicked.
HTML:
<label>
<input id="custom-checkbox" type="checkbox" required>
Disclaimer: Click here if you are okay...
</label>
Like Mr_Green was saying, you could hide the checkbox and use the label. Make sure you have the label after the checkbox, not the label wrapping the checkbox.
/* CheX */
input.chkrad {
display: none;
}
input.chkrad + label {
color: #111;
font-size: 16px;
background: url(http://i.imgur.com/clMMf.png) no-repeat; background-size: cover;
}
input.chkrad + label span {
display: inline-block;
width: 12px;
height: 12px;
margin: -1px 4px 0 0;
vertical-align: baseline;
cursor: pointer;
}
input + label span {
background: #fff;
line-height: 100%;
}
input.X:checked + label span {
padding: -3px 0 3px;
}
input.X:checked + label span:before {
content: 'X';
color: #F00;
font-family: cursive;
font-style: oblique;
font-weight: 900;
}
<input type='checkbox' name='chk3' id="chk3" class="chkrad X fade" value='x' />
<label for="chk3"><span></span> Disclaimer: Click anywhere on this text if you are okay...</label>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With