Created
November 25, 2015 11:45
-
-
Save butchi/15fcf0b048e6a6ff10ce to your computer and use it in GitHub Desktop.
カスタムUIのチェックボックス・ラジオボタン ref: http://qiita.com/butchi_y/items/936eff265e45c6a2165d
This file contains hidden or 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 { | |
background-color: #fff; | |
} | |
input[type="checkbox"], | |
input[type="radio"] { | |
position: absolute; | |
width: 0; | |
height: 0; | |
top: 0; | |
left: 0; | |
opacity: 0; | |
} | |
input[type="checkbox"] + *, | |
input[type="radio"] + * { | |
position: relative; | |
display: inline-block; | |
box-sizing: border-box; | |
} | |
[type="checkbox"] + * { | |
margin-left: 17px; | |
padding-left: -3px; | |
line-height: 12px; | |
} | |
[type="checkbox"] + *::before, | |
[type="checkbox"] + *::after { | |
content: ""; | |
display: block; | |
position: absolute; | |
box-sizing: border-box; | |
width: 12px; | |
height: 12px; | |
left: -14px; | |
top: 0px; | |
} | |
[type="checkbox"] + *::before { | |
background-color: #fff; | |
border: 1px solid #000; | |
} | |
[type="checkbox"]:checked + *::after { | |
position: absolute; | |
width: 6px; | |
height: 6px; | |
margin-left: 3px; | |
margin-top: 3px; | |
background: #000; | |
} | |
[type="radio"] + * { | |
margin-left: 17px; | |
padding-left: 0; | |
line-height: 16px; | |
} | |
[type="radio"] + *::before, | |
[type="radio"] + *::after { | |
box-sizing: border-box; | |
content: ""; | |
display: block; | |
position: absolute; | |
width: 16px; | |
height: 16px; | |
left: -16px; | |
top: 0px; | |
} | |
[type="radio"] + *::before { | |
background-color: #fff; | |
border: 1px solid #000; | |
border-radius: 16px; | |
} | |
[type="radio"]:checked + *::after { | |
position: absolute; | |
width: 8px; | |
height: 8px; | |
margin-left: 4px; | |
margin-top: 4px; | |
background: #000; | |
border-radius: 8px; | |
} | |
[type="checkbox"]:disabled + *::before, | |
[type="checkbox"]:disabled + *::after, | |
[type="radio"]:disabled + *::before, | |
[type="checkbox"]:disabled + *::after { | |
opacity: 0.25; | |
} | |
[type="checkbox"]:focus + *::before, | |
[type="radio"]:focus + *::before { | |
box-shadow: 1px 1px 0px #000; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment