Created
July 10, 2014 08:28
-
-
Save BenRichter/a99a5e79532505150359 to your computer and use it in GitHub Desktop.
Custom Checkbox
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 method="post" action="#"> | |
<label class="radio"> | |
<span class="styled"><input id="optionsRadios1" type="radio" checked="" value="option1" name="optionsRadios" checked></span> | |
Ja | |
</label> | |
<label class="radio"> | |
<span class="styled"><input id="optionsRadios2" type="radio" value="option2" name="optionsRadios"></span> | |
Nein | |
</label> | |
<label class="radio"> | |
<span class="styled"><input id="optionsRadios3" type="radio" value="option2" name="optionsRadios"></span> | |
Vielleicht | |
</label> | |
<input type="submit" value="Abstimmen »"> | |
</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
//$(document).ready(function(){ | |
$(window).load(function(){ | |
if ($('input[type="radio"]').length > 0){ | |
$(".styled input:checked").parent().addClass("checked"); | |
$(document).on("change", ".styled input", function() { | |
var $this = $(this); | |
var form = $this.closest("form"); | |
form.find("input[name='"+$this.attr("name")+"']").parent().removeClass("checked"); | |
$this.parent().addClass("checked"); | |
}); | |
} | |
}); |
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
label { | |
display: block; | |
color: @color-font-dark; | |
.font-family-dosis-light(); | |
.fontToEm(18); | |
span { | |
&.styled { | |
background: url(../gfx/img/checkbox-sprite.png) 0 0 no-repeat scroll transparent; | |
display: inline-block; | |
vertical-align: middle; | |
width: 26px; | |
height: 26px; | |
cursor: pointer; | |
margin: 5px 15px 5px 0; | |
} | |
&.styled.checked { | |
background-position: 0 -26px; | |
} | |
&.styled input { | |
position: absolute; | |
z-index: -1; | |
} | |
} | |
} | |
input[type="submit"]{ | |
width: 100%; | |
height: 28px; | |
border: 0 none; | |
background: @color-red; | |
line-height: 25px; | |
padding: 0 8px 0 14px; | |
text-decoration: none; | |
.font-family-gudea-regular(); | |
.fontToEm(13); | |
.lineToEm(17, 13); | |
color: #FFF; | |
&:hover{ | |
text-decoration: none!important; | |
background: #FF8682; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment