A Pen by Captain Anonymous on CodePen.
Created
August 23, 2016 00:35
-
-
Save CodeMyUI/130ee38bffae26b812c01ad8f859051b to your computer and use it in GitHub Desktop.
akrrVv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form> | |
<input required='' type='text'> | |
<label alt='Email' placeholder='Type your Email'></label> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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