Last active
July 26, 2016 03:24
-
-
Save patw0929/884e2efcfa2bab51573d98011df159a9 to your computer and use it in GitHub Desktop.
Pure CSS text input with required tip
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
<div class="wrapper"> | |
<input type="text" required> | |
<span class="tip">Required!</span> | |
</div> |
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
input:invalid { | |
outline: 1px solid red; | |
} | |
.tip { | |
display: none; | |
} | |
input:invalid + .tip { | |
display: inline-block; | |
color: #fff; | |
background-color: #f00; | |
margin-left: 10px; | |
padding: 2px; | |
position: relative; | |
} | |
.tip:after { | |
position: absolute; | |
left: -10px; | |
top: 0; | |
bottom: 0; | |
margin: auto; | |
content: ''; | |
width: 0; | |
height: 0; | |
border-top: 5px solid transparent; | |
border-bottom: 5px solid transparent; | |
border-right: 10px solid red; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment