Created
November 20, 2019 07:29
-
-
Save wnas/ae413c427631678bae6b553f20c2cbdc to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/zagoxoy
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="description" content="styling for input states"> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style id="jsbin-css"> | |
body { | |
font-family: verdana, sans-serif; | |
font-size: 2em; | |
background-color: #fff; | |
max-width: 20em; | |
margin: 0 auto; | |
} | |
p { | |
display: flex; | |
} | |
label { | |
display: inline-block; | |
width: 8em; | |
margin-right: 1em; | |
} | |
input { | |
border: 1px solid #ccc; | |
font-size: 1em; | |
} | |
label { | |
position: relative; | |
} | |
label:after { | |
position: absolute; | |
top: 0; | |
right: -.8em; | |
} | |
.required label:after { | |
content: '*'; | |
} | |
.invalid label:after { | |
content: 'x'; | |
color: red; | |
} | |
.invalid input { | |
border-color: red; | |
} | |
.valid label:after { | |
content: '√'; | |
color: green; | |
} | |
.valid input { | |
border-color: green; | |
} | |
</style> | |
</head> | |
<body> | |
<form action=""> | |
<p class="required"><label for="a">Required</label><input id="a" placeholder="fill me in" required type="text"></p> | |
<p class="invalid"><label for="b">Invalid</label><input placeholder="alaaf" id="b" type="text"></p> | |
<p class="valid"><label for="c">Valid</label><input placeholder="a11y" id="c" type="text"></p> | |
</form> | |
<script id="jsbin-source-css" type="text/css">body { | |
font-family: verdana, sans-serif; | |
font-size: 2em; | |
background-color: #fff; | |
max-width: 20em; | |
margin: 0 auto; | |
} | |
p { | |
display: flex; | |
} | |
label { | |
display: inline-block; | |
width: 8em; | |
margin-right: 1em; | |
} | |
input { | |
border: 1px solid #ccc; | |
font-size: 1em; | |
} | |
label { | |
position: relative; | |
} | |
label:after { | |
position: absolute; | |
top: 0; | |
right: -.8em; | |
} | |
.required label:after { | |
content: '*'; | |
} | |
.invalid label:after { | |
content: 'x'; | |
color: red; | |
} | |
.invalid input { | |
border-color: red; | |
} | |
.valid label:after { | |
content: '√'; | |
color: green; | |
} | |
.valid input { | |
border-color: green; | |
}</script> | |
</body> | |
</html> |
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
body { | |
font-family: verdana, sans-serif; | |
font-size: 2em; | |
background-color: #fff; | |
max-width: 20em; | |
margin: 0 auto; | |
} | |
p { | |
display: flex; | |
} | |
label { | |
display: inline-block; | |
width: 8em; | |
margin-right: 1em; | |
} | |
input { | |
border: 1px solid #ccc; | |
font-size: 1em; | |
} | |
label { | |
position: relative; | |
} | |
label:after { | |
position: absolute; | |
top: 0; | |
right: -.8em; | |
} | |
.required label:after { | |
content: '*'; | |
} | |
.invalid label:after { | |
content: 'x'; | |
color: red; | |
} | |
.invalid input { | |
border-color: red; | |
} | |
.valid label:after { | |
content: '√'; | |
color: green; | |
} | |
.valid input { | |
border-color: green; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment