HTML:
<form method="post" action="#" autocomplete="off" id="validform">
<div class="form-group col-sm-6">
<input type="text" class="form-control" id="name" required>
<span class="underline"></span>
<label for="name">Your name</label>
</div>
<div class="form-group col-sm-6">
<input type="email" class="form-control" id="email" required>
<span class="underline"></span>
<label for="email">Email</label>
CSS:
input:focus ~ label,
input:valid ~ label,
textarea:focus ~ label,
textarea:valid ~ label
{
font-size: .8em;
top: -20px;
color: #24cf88;
}
So basically label shifts on top of an input tag whenever you focus on input tag or if it is valid . it works fine with text input , but with an email input it shifts back to the bottom unless you type the correct email format. How can i keep the text shifted to the top after i type something in an email input ?? i've included the link to the website if you'd like to check how it works.