I am trying to get the floating label effect on Contact Form 7 and ran into a problem. I got the label effect to work on input:focus but I can not get the effect to hold once I enter letters and move to the next input.
In other words I need to label to stay up when the input is not empty.
here's my code:
<div class="wrapper-flex wrapper-form">
<div class="input-wrapper">
<label for="your-name"> [text* your-name]<span class="eticheta">FULL NAME</span></label>
</div><!-- input-wrapper -->
</div><!-- wrapper-flex -->
and the css:
.wpcf7-form .input-wrapper{
width:47%;
height: 50px;
position: relative;
}
.wpcf7-form input{
width:100% !important;
background: none !important;
border:none !important;
height: 30px !important;
margin:20px 0 0 0 !important;
}
.wpcf7-form .eticheta{
width: 100%;
display: block;
transition: all 0.3s ease;
position: absolute;
top:10px;
}
.wpcf7-form label:focus-within .eticheta, .wpcf7-form input:valid + .eticheta
{
top:0px;
}
I understand that .wpcf7-form input:valid + .eticheta doesn't work as they do not have the same parent. The input has a span around it. I am guessing that's why it doesn't work but I cannot figure out how to get it done