Skip to content

Instantly share code, notes, and snippets.

@robjstanley
Created July 4, 2018 08:28
Show Gist options
  • Save robjstanley/3c86e58d5bd5f6046eebd85041356c98 to your computer and use it in GitHub Desktop.
Save robjstanley/3c86e58d5bd5f6046eebd85041356c98 to your computer and use it in GitHub Desktop.
CSS Only Placeholder Move
<style>
label {
margin:20px 0;
position:relative;
display:inline-block;
span {
padding:10px;
pointer-events: none;
position:absolute;
left:0;
top:0;
transition: 0.2s;
transition-timing-function: ease;
transition-timing-function: cubic-bezier(0.25, 0.1, 0.25, 1);
opacity:0.5;
}
input {
padding:10px;
}
input:focus + span, input:not(:placeholder-shown) + span {
opacity:1;
transform: scale(0.75) translateY(-100%) translateX(-25px);
}
}
</style>
<label>
<input placeholder=" ">
<span>Placeholder Text</span>
</label>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment