Skip to content

Instantly share code, notes, and snippets.

@maxcraftsman
Last active April 11, 2018 06:17
Show Gist options
  • Save maxcraftsman/a13c4210b17c423c1d0e71e088fe2d8a to your computer and use it in GitHub Desktop.
Save maxcraftsman/a13c4210b17c423c1d0e71e088fe2d8a to your computer and use it in GitHub Desktop.
Animated input placeholder
<label class="reverse-input">
<input type="text" placeholder="" required="">
<em>Фамилия и имя</em>
</label>
<style>
.reverse-input {
display: flex;
flex-direction: column;
& em {
padding: 0 5px;
position: absolute;
top: 7px;
left: 15px;
font-style: normal;
font-size: 16px;
transition: all 0.15s ease-in-out;
cursor: text;
}
& input:valid+em, & textarea:valid+em, & input:focus+em, & textarea:focus+em {
background-color: white;
top: -10px;
font-size: 12px;
color: #999999;
}
span {
line-height: 1.2;
margin-bottom: 5px;
}
*:first-child {
order: 2;
}
input[required] + span:after{
content: " *";
color: red;
}
input, textarea {
background-color: #f9f9f9;
border: 1px solid #eeeeee;
}
input:focus, textarea:focus {
border: 1px solid #ccc !important;
}
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment