I have the simple form below (and here: https://codepen.io/anon/pen/QxKrex). The checkbox works when you click on it, but I would like that when you have the focus on it (after a "tab" from the textfield) and press spacebar, it would be marked as well. However, it doesn't seem to work. Any ideas?
index.html
.labelCheckbox {
display: contents;
}
.checkbox label {
float: left;
padding-left: 0px !important;
font-size: initial;
}
input[type=checkbox] {
opacity: 0;
}
input[type="checkbox"]{
display: none;
}
input[type="checkbox"] + label::before{
background-color: white;
border: 1px solid #135BCF;
content: '';
display: inline-block;
height: 22px;
width: 22px;
text-align: center;
margin: 0 5px -2px 0;
overflow: hidden;
top: 3px;
position: relative;
float: initial;
}
input[type="checkbox"]:checked + label::before{
content: '\2713';
}
<form action="/send.php" method="post" name="myForm">
<label for="fname"></label>
<input type="text" id="fname" name="fname" placeholder="Name" required>
<input type="checkbox" id="checkbox1">
<label for="checkbox1" tabindex="0;"></label>
<label class="labelCheckbox">  I agree</label>
<button class="modalButton" type="submit" value="submit" id="submit2">Submit</button>
</form>
Aucun commentaire:
Enregistrer un commentaire