"Sweetbox : Custom radio and checkbox"
Bootstrap 4.1.1 Snippet by insiteout

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js" integrity="sha384-LtrjvnR4Twt/qOuYxE721u19sVFLVSA4hf/rRt6PrZTmiPltdZcI7q7PXQBYTKyf" crossorigin="anonymous"></script>
<div class="container">
<div class="row">
<div class="col-12">
<h2>Bootsprap 4.1 pure CSS custom radios and checkboxes</h2>
</div>
<div class="col-6">
<div class="card mb-3">
<div class="card-header small">
<i class="far fa-dot-circle fa-fw"></i>
Direction: column
</div>
<div class="card-body">
<!-- RADIOS IN COLUMN START -->
<div class="sweetbox-group sweetbox-group-column">
<div class="sweetbox sweetbox-md">
<input type="radio" name="radio_col" id="radio_col_1" value="1" />
<label for="radio_col_1">Lorem ipsum dolor sit amet</label>
</div>
<div class="sweetbox sweetbox-md">
<input type="radio" name="radio_col" id="radio_col_2" value="2" />
<label for="radio_col_2">Consectetur adipiscing elit</label>
</div>
<div class="sweetbox sweetbox-md">
<input type="radio" name="radio_col" id="radio_col_3" value="3" />
<label for="radio_col_3">Curabitur vitae laoreet orci</label>
</div>
<div class="sweetbox sweetbox-md">
<input type="radio" name="radio_col" id="radio_col_4" checked="checked" value="4" />
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
.sweetbox-group {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
align-items: stretch;
align-content: space-between;
}
.sweetbox-group.sweetbox-group-row {
flex-direction: row;
}
.sweetbox-group.sweetbox-group-column {
flex-direction: column;
}
.sweetbox-group.sweetbox-group-row > .sweetbox {
align-self: center;
}
.sweetbox-group.sweetbox-group-column > .sweetbox {
align-self: flex-start;
width: 100%;
}
.sweetbox-group > .sweetbox {
flex-grow: 1;
flex-shrink: 1;
}
.sweetbox-group > .sweetbox > input[type="radio"], .sweetbox-group > .sweetbox > input[type="checkbox"] {
display: none;
}
/* SMALL */
.sweetbox-group > .sweetbox.sweetbox-sm > label {
position: relative;
height: 10px;
font-size: 9px;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: