Skip to content

Instantly share code, notes, and snippets.

@CodeMyUI
Created August 23, 2016 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CodeMyUI/130ee38bffae26b812c01ad8f859051b to your computer and use it in GitHub Desktop.
Save CodeMyUI/130ee38bffae26b812c01ad8f859051b to your computer and use it in GitHub Desktop.
akrrVv
<form>
<input required='' type='text'>
<label alt='Email' placeholder='Type your Email'></label>
</form>
html, body {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
input[type="text"] {
box-sizing: border-box;
width: 100%;
height: calc(4em + 1px);
margin: 0 0 1em;
padding: 1em;
border: 1px solid #ccc;
background: #fff;
resize: none;
outline: none;
}
input[type="text"][required]:focus {
border-color: #00bafa;
}
input[type="text"][required]:focus + label[placeholder]:before {
color: #00bafa;
}
input[type="text"][required]:focus + label[placeholder]:before,
input[type="text"][required]:valid + label[placeholder]:before {
transition-duration: .2s;
transform: translate(0, -1.5em) scale(0.9, 0.9);
}
input[type="text"][required]:invalid + label[placeholder][alt]:before {
content: attr(alt);
}
input[type="text"][required] + label[placeholder] {
display: block;
pointer-events: none;
line-height: 1em;
margin-top: calc(-3em - 2px);
margin-bottom: calc((3em - 1em) + 2px);
}
input[type="text"][required] + label[placeholder]:before {
content: attr(placeholder);
display: inline-block;
margin: 0 calc(1em + 2px);
padding: 0 2px;
color: #898989;
white-space: nowrap;
transition: 0.3s ease-in-out;
background-image: linear-gradient(to bottom, #fff, #fff);
background-size: 100% 5px;
background-repeat: no-repeat;
background-position: center;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment