I want to move a label above an input box when a user focuses on the input box. There is an answer here, however, there are some differences. I can't use required as I am using custom validations. Also, there is more than one input box.
See my code below. I must be missing something silly.
.field {
position: relative;
padding-top: 10px;
}
.form label {
position: absolute;
top: 8px;
left: 10px;
pointer-events: none;
}
input:focus ~ label {
top: -6px;
}
<form class="form">
<div class="field">
<label>Name</label>
<input type="text">
</div>
<div class="field">
<label>Age</label>
<input type="text">
</div>
</form>