I've been working on styling a checkbox with some code. However, the checkbox mark is not hidden by default. I would like the mark to be hidden initially and only shown when selected. Can someone please help me solve this issue? Thank you in advance.
.checkbox {
width: 38px;
height: 38px;
margin: 10px;
// border: 1px solid #000;
background: #A53692; /*blue purple*/
}
.label {
position: relative;
width: 645px;
margin: 10px;
padding-left: 20px;
line-height: 38px;
text-align: left;
color: #fff;
background: #A53692; /*blue purple*/
cursor: pointer;
}
.checkbox input[type=checkbox] {
content: "";
width: 38px;
height: 38px;
margin: 0;
left: 0;
opacity: 0;
cursor: pointer;
}
.label label::after {
content: "";
height: 6px;
width: 9px;
border-left: 2px solid;
border-bottom: 2px solid;
transform: rotate(-45deg);
position: absolute;
left: -45px;
top: 14px;
cursor: pointer;
}
/*Hide the checkmark by default*/
.checkbox input[type="checkbox"] + .label label::after {
content: none;
}
/*Unhide the checkmark on the checked state*/
.checkbox input[type="checkbox"]:checked + .label label::after {
content: "";
<div class="request-sample-form-items">
<div class="checkbox"><input type="checkbox" id="checkbox"></div>
<div class="label"><label for="checkbox">Select if you want to fill this form automatically next time.</label></div>
</div>