Forked from rcotrina94/How to use Images as Radio buttons.md
Last active
November 30, 2017 17:38
-
-
Save kovtunos/9e5c0743cc04eb57d7d1de52235c6bd4 to your computer and use it in GitHub Desktop.
How to use images for radio buttons (input-radio) #css
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
<form> | |
<div class="cc-selector"> | |
<input id="visa" type="radio" name="credit-card" value="visa" /> | |
<label class="drinkcard-cc visa" for="visa"></label> | |
<input id="mastercard" type="radio" name="credit-card" value="mastercard" /> | |
<label class="drinkcard-cc mastercard"for="mastercard"></label> | |
</div> | |
</form> |
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
.cc-selector input { | |
margin: 0; | |
padding: 0; | |
appearance: none; | |
visibility: hidden; | |
} | |
.visa { | |
background-image: url('http://i.imgur.com/lXzJ1eB.png'); | |
} | |
.mastercard { | |
background-image: url('http://i.imgur.com/SJbRQF7.png'); | |
} | |
.cc-selector input:active + label { | |
opacity: 0.9; | |
} | |
.cc-selector input:checked + label { | |
filter: none; | |
} | |
.drinkcard-cc { | |
cursor: pointer; | |
background-size: contain; | |
background-repeat: no-repeat; | |
display: inline-block; | |
width: 100px; | |
height: 70px; | |
transition: all 100ms ease-in; | |
filter: brightness(1.8) grayscale(1) opacity(.7); | |
} | |
.drinkcard-cc:hover { | |
filter: brightness(1.2) grayscale(.5) opacity(.9); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment