I have this sample:
CODE HTML:
<div class="field">
<label>First Name</label>
<div class="control">
<input type="text" class="input-text">
</div>
</div>
CODE CSS:
.field{
position: relative;
}
.label {
position: absolute;
pointer-events: none;
left: 10px;
top: 2px;
transition: 0.2s ease all;
font-size: 15px;
}
input:focus ~ .label,
input:not(:focus):valid ~ .label {
top: -6px;
}
Basically I want when the user writes something in the input, the label is moved over the input.
Can this be obtained only from the css?
Can you please change the example I created to understand exactly how this is done?
Thanks in advance!