I am trying to add some simple animation to a label so when you click in the form field the label slides up - much like a Material Design animation effect.
The issue I have is that we are using a Hubspot form thats pulled into the page so I actually have no control on the markup.
Before I go asking our front end devs im just wondering if this is actually possible with plain CSS?
This is basically how the code looks for the form:
<div class="hs-firstname">
<label>Enter First Name</labe>
<div class="input">
<input class="hs-input firstname"/>
</div>
</div>
so would naturally think to try something like:
input{position:relative;}
label{position:absolute; top:0; left:0; font-size:18px; transition: all 0.2s ease-in-out;}
input:focus ~ label{top:-15px; font-size:12px;}
The issue is the nesting of the input field inside its own div, which again is something out of my control.
otherwise this would be straightforward.
So just wondering if anyone might know a way around this with Pure CSS or if is does indeed need some react.js (which the page is built in)
Thanks in advance