JSFiddle - React, Tailwind, and code Playground
Check Boxes & Radios
by Jennifer Perrin
HTML
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
<div class="crb-boxes">
<label class="crb crb_checkbox">First Selection
<input type="checkbox" name="crb1" id="crb1" value="crb1" checked="checked" />
<div class="crb_indicator"></div>
</label>
<label class="crb crb_checkbox">Second Selection
<input type="checkbox" name="crb2" id="crb2" value="crb2" />
<div class="crb_indicator"></div>
</label>
<label class="crb crb_checkbox">Third Selection
<input type="checkbox" name="crb3" id="crb3" value="crb3" />
<div class="crb_indicator"></div>
</label>
</div>
<div class="crb-boxes">
<label class="crb crb_radio">First Option
<input type="radio" name="crbradio" id="crbradio1" value="crbradio1" checked="checked" />
<div class="crb_indicator"></div>
</label>
<label class="crb crb_radio">Second Option
<input type="radio" name="crbradio" id="crbradio2" value="crbradio2" />
<div class="crb_indicator"></div>
</label>
<label class="crb crb_radio">Third Option
<input type="radio" name="crbradio" id="crbradio3" value="crbradio3" />
<div class="crb_indicator"></div>
</label>
<label class="crb crb_radio">Fourth Option
<input type="radio" name="crbradio" id="crbradio4" value="crbradio4" />
<div class="crb_indicator"></div>
</label>
</div>
CSS
@import url(//fonts.googleapis.com/css?family=Muli);
* { border-radius: 0 !important; }
html, body {
height: 100%;
}
body {
padding: 20px;
margin: 0;
font-family: 'Muli', sans-serif;
font-size: 16px;
color: #676e74;
background: #e9eef1;
}
a {
color: #1f2123;
transition: all 0.2s ease-in-out 0s;
}
a:hover {
color: #308eb1;
text-decoration: none;
}
/* ==========================================================================
Checkboxes & Radio Buttons
========================================================================== */
.crb-boxes { margin-bottom: 15px; }
.crb-boxes .crb:last-of-type { margin-right: 0; }
.crb {
display: inline-block;
position: relative;
padding-left: 30px;
margin-right: 20px;
cursor: pointer;
font-size: 16px;
}
.crb input {
position: absolute;
z-index: -1;
opacity: 0;
}
.crb_indicator {
position: absolute;
top: 2px;
left: 0;
height: 20px;
width: 20px;
background: #e6e6e6;
}
.crb_radio .crb_indicator { border-radius: 50% !important; }
.crb:hover input ~ .crb_indicator, .crb input:focus ~ .crb_indicator { background: #ccc; }
.crb input:checked ~ .crb_indicator { background: #308eb1; }
.crb:hover input:not([disabled]):checked ~ .crb_indicator, .crb input:checked:focus ~ .crb_indicator { background: #0e647d; }
.crb input:disabled ~ .crb_indicator {
background: #e6e6e6;
opacity: 0.6;
pointer-events: none;
}
.crb_indicator:after {
content: '';
position: absolute;
display: none;
}
.crb input:checked ~ .crb_indicator:after { display: block; }
.crb_checkbox .crb_indicator:after {
left: 9px;
top: 5px;
width: 3px;
height: 8px;
border: solid #fff;
border-width: 0 2px 2px 0;
transform: rotate(45deg);
}
.crb_checkbox input:disabled ~ .crb_indicator:after { border-color: #7b7b7b; }
.crb_radio .crb_indicator:after {
left: 7px;
top: 7px;
height: 6px;
width: 6px;
border-radius: 50% !important;
background: #fff;
}
.crb_radio input:disabled ~...