Custom Radio Buttons

Styled radio buttons to look more like Twitter's Bootstrap.

by Daniel Flores

HTML

<div class='radio-btn group'>
    <input type="radio" id="radio1" name="radios" value="all" checked='checked'>
    <label for="radio1" class="radio-label">Radio1</label>
    
    <input type="radio" id="radio2" name="radios"value="false">
    <label for="radio2" class="radio-label">Radio2</label>
        
    <input type="radio" id="radio3" name="radios"value="false">
    <label for="radio3" class="radio-label">Radio3</label>
</div>

CSS

.radio-btn label {
    /* Display */
    display: inline-block;
    cursor: pointer;
    padding: 7px 7px;
    margin-bottom: 0;
    text-align: left;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
    vertical-align: middle;
    margin-bottom: 5px;
    
    /* Font */
    font-size: 14px;
    color: #333333;
    line-height: 20px;
    font-weight: 700;
    
    /* Color */
    -moz-border-bottom-colors: none;
    -moz-border-left-colors: none;
    -moz-border-right-colors: none;
    -moz-border-top-colors: none;
    background-color: #F5F5F5;
    background-image: linear-gradient(to bottom, #FFFFFF, #E6E6E6);
    background-repeat: repeat-x;
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) #B3B3B3;
    border-image: none;
    border-radius: 4px;
    border-style: solid;
    border-width: 1px;
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset, 0 1px 2px rgba(0, 0, 0, 0.05);
}
.radio-btn input[type="radio"] {
    display:none;
}
.radio-btn input[type="radio"]:checked + label { 
    /* Font */
    color: #FFFFFF;
    text-shadow: 0 1px 1px rgba(16, 148, 209, 0.75);
    /* Cursor */
    cursor: default;
    /* Border */
    border: 1px solid #1094d1;
    border-color: #1094d1 #1094d1 #0b6996 #1094d1;
    /* Blue Gradient */
    background: #037fba; /* Old browsers */
    background: -moz-linear-gradient(top,  #037fba 0%, #037fba 49%, #1086be 50%, #0377b4 51%, #0376b2 100%); /* FF3.6+ */
    background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#037fba), color-stop(49%,#037fba), color-stop(50%,#1086be), color-stop(51%,#0377b4), color-stop(100%,#0376b2)); /* Chrome,Safari4+ */
    background: -webkit-linear-gradient(top,  #037fba 0%,#037fba 49%,#1086be 50%,#0377b4 51%,#0376b2 100%); /* Chrome10+,Safari5.1+ */
    background: -o-linear-gradient(top,  #037fba 0%,#037fba 49%,#1086be 50%,#0377b4 51%,#0376b2 100%); /* Opera 11.10+ */
    background: -ms-linear-gradient(top,  #037fba 0%,#037fba 49%,#1086be 50%,#0377b4 51%,#0376b2...

JavaScript

$('input[type="radio"]').on('change', function(){
    //console.log($(this).is(':checked'));
    console.log('1: '+$('#radio1').is(':checked'));
    console.log('2: '+$('#radio2').is(':checked'));
});