Quick Reach
What is Bootstrap checkbox?
The checkbox allows a user to select multiple options from the available values. The Bootstrap framework includes a number of CSS classes related to building HTML forms. By simply including classes into the <form> tag or its elements you can build beautiful forms using Bootstrap for your website. This also includes classes for the checkboxes.
Following examples show how to use a checkbox in the Bootstrap forms.
Example of using checkbox in Bootstrap form
Following example shows an example of “Account creation” form that uses a checkbox as well. We simply used checkbox class in div, wrapping the checkbox.
Experience this online
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
<!DOCTYPE html>
<html>
<head>
<title>Example of checkbox in Bootstrap form</title>
<link rel=“stylesheet” href=“//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css”>
<script src=“http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script>
<script src=“http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js”></script>
</head>
<body>
<div>
<h1>Bootstrap dropdown example</h1>
<form class=“form-horizontal” role=“form”>
<div class=“form-group”>
<label for=“name1”>Name</label>
<div class=“col-sm-5”>
<input type=“email” id=“name1” placeholder=“Full Name”>
</div>
</div>
<div class=“form-group”>
<label for=“gender1”>Gender</label>
<div class=“col-sm-2”>
<select class=“form-control” id=“gender1”>
<option>Male</option>
<option>Female</option>
</select>
</div>
</div>
<div class=“form-group”>
<label for=“email1”>Email</label>
<div class=“col-sm-5”>
<input type=“email” id=“email1” placeholder=“Email”>
</div>
</div>
<div class=“form-group”>
<label for=“password1”>Password</label>
<div class=“col-sm-5”>
<input type=“password” class=“form-control” id=“password1” placeholder=“Password”>
</div>
</div>
<div class=“form-group”>
<label for=“address1”>Address</label>
<div class=“col-sm-5”>
<input type=“email” id=“address1” placeholder=“Address”>
</div>
</div>
<div class=“form-group”>
<div class=“col-sm-offset-2 col-sm-10”>
<div class=“checkbox”>
<label>
<input type=“checkbox”> Remember me
</label>
</div>
</div>
</div>
<div class=“form-group”>
<div class=“col-sm-offset-2 col-sm-10”>
<button type=“submit”>Create Account</button>
</div>
</div>
</form>
</div>
</body>
</html>
|
You can see, “Remember me” checkbox in the above example.
Using multiple checkboxes in a Bootstrap form example
The following example shows how to use multiple checkboxes inline i.e. rather each checkbox uses a new line, all will be shown on the same line by using the Bootstrap checkbox-inline class.
Experience this online
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
38
39
40
41
42
43
44
45
46
47
|
<!DOCTYPE html>
<html>
<head>
<title>Example of multiple checkboxes in Bootstrap form</title>
<link rel=“stylesheet” href=“//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css”>
<script src=“http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js”></script>
<script src=“http://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js”></script>
</head>
<body>
<div>
<h1>Bootstrap dropdown example</h1>
<label class=“checkbox-inline”>
<input type=“checkbox” id=“inlineCheckbox1” value=“option1”> option 1
</label>
<label class=“checkbox-inline”>
<input type=“checkbox” id=“inlineCheckbox2” value=“option2”> option 2
</label>
<label class=“checkbox-inline”>
<input type=“checkbox” id=“inlineCheckbox3” value=“option3”> option 3
</label>
</div>
</div>
</body>
</html>
|
Useful links: The Bootstrap Tutorial | Table in Bootstrap framework| Bootstrap Form
Leave A Comment?