Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Visual Radio Button Groups"
Bootstrap 3.0.0 Snippet by
franzone
3.0.0
radio
Preview
HTML
CSS
View Full Screen
Fork
Fork this
7.8K
 
4 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="col-md-12"> This allows you to represent a radio button group as a Bootstrap Button Group, with visual indicators as to which item has been <em>"checked"</em>. I got the idea from the <a href="https://bootsnipp.com/snippets/Zk2Pz">Funky Radio/Checkbox Buttons V2.0</a>. </div> </div> <div class="row"> <h2>Default Button Group</h2> <div class="btn-group"> <label class="btn btn-default"> <input type="radio" name="testrad" value="0"> <span>One Value</span> </label> <label class="btn btn-default"> <input type="radio" name="testrad" value="1"> <span>Two Value</span> </label> <label class="btn btn-default"> <input type="radio" name="testrad" value="2"> <span>Three Value</span> </label> </div> </div> <div class="row"> <h2>Primary Button Group</h2> <p>This looks terrible!</p> <div class="btn-group"> <label class="btn btn-primary"> <input type="radio" name="testrad" value="0"> <span>One Value</span> </label> <label class="btn btn-primary"> <input type="radio" name="testrad" value="1"> <span>Two Value</span> </label> <label class="btn btn-primary"> <input type="radio" name="testrad" value="2"> <span>Three Value</span> </label> </div> </div> </div>
.btn-group label { padding-left: 40px; } input[type="radio"]:empty { display: none; } input[type="radio"] ~ span:before { position: absolute; display: block; top: 0; bottom: 0; left: 0; content: ''; width: 2.5em; background: #D1D3D4; } input[type="radio"]:before { content: '\2714'; text-indent: .9em; color: #C2C2C2; } input[type="radio"]:checked ~ span:before { content: '\2714'; text-indent: .3em; color: #fff; background-color: #5cb85c; line-height: 2.5em; }
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76