I'm trying to create a floating label effect for textboxes in my form that moves up on hover and focus. However, I'm running into an issue where the text gets hidden when the label moves up.
Below is the HTML and CSS code I've been working with:
.float-label {
position: absolute;
left: 0;
top: 0;
padding: 10px 6px;
color: #767676;
pointer-events: none;
transition: 0.2s ease all;
}
.form-control:focus ~ .float-label,
.form-control:not(:focus):valid ~ .float-label {
top: -18px;
margin-left:5px;
font-size: 12px;
opacity: 1;
z-index: 1;
background-color: white;
}
<div class="form-group border-lable-flt">
<input type="email" class="form-control" id="work_email" required>
<label class="float-label" for="workEmail">Work email</label>
</div>