Professional Documents
Culture Documents
Boostrap 1
Boostrap 1
Introduction
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<ul class="list-group">
<li class="list-group-item">Pictures</li>
<li class="list-group-item">Documents</li>
<li class="list-group-item">Music</li>
<li class="list-group-item">Videos</li>
</ul>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
We can link list group items by using the hyperlink tag <a> of HTML. In this
code we replace the <li> tag with <a> and instead of <ul> we use the <div> as
parent. Using this code we can add badges and icons, where the badges will
appear on the right. <ul> with the class .list-group, where each list items have
the class .list-group-item.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div class="list-group">
</a>
</a>
</a>
</a>
</div>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
We can add HTML elements like headings and paragraph within the list groups.
In this code, we use <p> paragraph and <h> heading elements.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div class="list-group">
<p class="list-group-item-text">HTML stands for HyperText Markup Language. HTML is the main
markup language for describing the structure of Web pages.</p>
</a>
</a>
<p class="list-group-item-text">CSS stands for Cascading Style Sheet. CSS allows you to specify
various style properties for a given HTML element such as colors, backgrounds, fonts etc.</p>
</a>
</div>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
To specify the active list group item, we can use the class .active
In this code, this is achieved by using the <div> parent element and
hyperlink tag <a> to make the active item as a link.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 List Group Contextual Classes</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<ul class="list-group">
<li class="list-group-item list-group-item-success">200 OK: The server successfully
processed the request.</li>
<li class="list-group-item list-group-item-info">100 Continue: The client should continue
with its request.</li>
<li class="list-group-item list-group-item-warning">503 Service Unavailable: The server is
temporarily unable to handle the request.</li>
<li class="list-group-item list-group-item-danger">400 Bad Request: The request cannot be
fulfilled due to bad syntax.</li>
</ul>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
To specify the active list group item, we can use the class .active
In this code, this is achieved by using the <div> parent element and
hyperlink tag <a> to make the active item as a link.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 List Group Contextual Classes</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-success">200 OK: The server successfully
processed the request.</a>
<a href="#" class="list-group-item list-group-item-info active">100 Continue: The client
should continue with its request.</a>
<a href="#" class="list-group-item list-group-item-warning">503 Service Unavailable: The
server is temporarily unable to handle the request.</a>
<a href="#" class="list-group-item list-group-item-danger">400 Bad Request: The request
cannot be fulfilled due to bad syntax.</a>
</div>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
Out of three types of form layouts, the default form layout is Vertical Form.
In this code, styles are used on the form controls and we use
the <form> element without any base classes on it or any particular changes
in markup.
We have used textual elements like <input>, <textarea> and <select> with the
class .form-control and are 100% default wide.
Form controls are are stacked with labels left-aligned on top.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Vertical Form Layout</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form>
<div class="form-group">
<label for="inputEmail">Email</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<div class="form-group">
<label for="inputPassword">Password</label>
<input type="password" class="form-control" id="inputPassword"
placeholder="Password">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
In Horizontal Form layout the labels are right-aligned and appear in the
same line of the form controls, but to make a horizontal form layout we
need to use so many markups.
In this code, we use class .form-horizontal to the <form> element.
It contians the labels and form element in the <div> element with the class
.form-group .
To align labels and form controls, we use predefined grid classes like .col-
xs
For the <label> element we use the class .control-label
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Horizontal Form Layout</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
<style type="text/css">
.bs-example {
margin: 20px;
}
/* Fix alignment issue of label on extra small devices in Bootstrap 3.2 */
.form-horizontal .control-label {
padding-top: 7px;
}
</style>
</head>
<body>
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail" class="control-label col-xs-2">Email</label>
<div class="col-xs-10">
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="control-label col-xs-2">Password</label>
<div class="col-xs-10">
<input type="password" class="form-control" id="inputPassword"
placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
There maybe situations in which we need to place just plain text to a form
label.
In this code, we have used the horizontal form layout and on a <p> element
we use the .form-control-static class.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Static Form Control</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
<style type="text/css">
.bs-example {
margin: 20px;
}
/* Fix alignment issue of label on extra small devices in Bootstrap 3.2 */
.form-horizontal .control-label {
padding-top: 7px;
}
</style>
</head>
<body>
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail" class="control-label col-xs-2">Email</label>
<div class="col-xs-10">
<p class="form-control-static">harrypotter@mail.com</p>
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="control-label col-xs-2">Password</label>
<div class="col-xs-10">
<input type="password" class="form-control" id="inputPassword"
placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
.bs-example {
margin: 20px;
.form-horizontal .control-label {
padding-top: 7px;
</style>
</head>
<body>
<form class="form-horizontal">
<div class="form-group">
<div class="col-xs-10">
<p class="form-control-static">harrypotter@mail.com</p>
</div>
</div>
<div class="form-group">
<div class="col-xs-10">
</div>
</div>
<div class="form-group">
<div class="checkbox">
</div>
</div>
</div>
<div class="form-group">
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
There will be instances where we want to match the size of our form
controls to the Bootstrap grid column sizes.
In this code, we wrap form controls (<input>, <textarea>, and <select>) into
grid columns or any custom element by applying the grid classes on it.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<div class="row">
<div class="col-xs-3">
</div>
<div class="col-xs-4">
</div>
<div class="col-xs-5">
</div>
</div>
<br>
<div class="row">
<div class="col-xs-3">
<textarea class="form-control"></textarea>
</div>
<div class="col-xs-4">
<textarea class="form-control"></textarea>
</div>
<div class="col-xs-5">
<textarea class="form-control"></textarea>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-3">
<select class="form-control">
<option>Select</option>
</select>
</div>
<div class="col-xs-4">
<select class="form-control">
<option>Select</option>
</select>
</div>
<div class="col-xs-5">
<select class="form-control">
<option>Select</option>
</select>
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
Using this code, we can disable text based inputs by adding the
attribute disabled to the <input> element described in the <form> element.
In the browser, we will see the "not-allowed" cursor when you put the mouse
pointer on the text label.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Disabled Inputs</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form>
<input type="text" class="form-control" placeholder="Disabled input" disabled="disabled">
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
Using this code, we can make text based inputs read only by adding the
attribute readonly to the <input> element.
This prevents the user from inputting anything, i.e., just read only.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Readonly Inputs</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form>
<input type="text" class="form-control" placeholder="Readonly input"
readonly="readonly">
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
My First Code
Introduction
Using this code, we can disable form controls within a fieldset by adding the
attribute disabled to the <fieldset> element.
This prevents the user from inputting anything in the fieldsets.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Disabled Inputs</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form>
<input type="text" class="form-control" placeholder="Disabled input" disabled="disabled">
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
Using this code, we can disable form controls within a fieldset by adding the
attribute disabled to the <fieldset> element.
This prevents the user from inputting anything in the fieldsets.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Disabled Fieldsets</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form class="form-horizontal">
<fieldset disabled="disabled">
<div class="form-group">
<label for="inputEmail" class="control-label col-xs-2">Email</label>
<div class="col-xs-10">
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputPassword" class="control-label col-xs-2">Password</label>
<div class="col-xs-10">
<input type="password" class="form-control" id="inputPassword"
placeholder="Password">
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-2 col-xs-10">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</div>
</fieldset>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
To help users enter the correct data in a form, we can place help texts for
the form controls.
For this purpose, we add the class .help-block to the <span> tag (used for
applying the style to display help text) and displaying it under the bottom of
the control.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Block Help Text</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form>
<input type="text" class="form-control">
<span class="help-block">A block of help text that breaks onto a new line and may extend
beyond one line.</span>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
We can also add optional feedback icons to our inputs using the class .has-
feedback on .form-group and using the right glyphicon (library of precise
monochromatic icons and symbols) to symbolize the validation states.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form class="form-horizontal">
<div class="col-xs-10">
</div>
</div>
<div class="col-xs-10">
</div>
</div>
<div class="col-xs-10">
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
Bootstrap gives support for all standard form controls as well as new
HTML5 input types.
New HTML5 input types are datetime, number, email, url, search, tel, color,
range etc
In this code, we have used the standard form controls like name, email,
phone number, etc.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Supported Form Controls</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<h1>Sign Up</h1>
<form class="form-horizontal">
<div class="form-group">
<label class="control-label col-xs-3" for="inputEmail">Email:</label>
<div class="col-xs-9">
<input type="email" class="form-control" id="inputEmail" placeholder="Email">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="inputPassword">Password:</label>
<div class="col-xs-9">
<input type="password" class="form-control" id="inputPassword"
placeholder="Password">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="confirmPassword">Confirm Password:</label>
<div class="col-xs-9">
<input type="password" class="form-control" id="confirmPassword"
placeholder="Confirm Password">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="firstName">First Name:</label>
<div class="col-xs-9">
<input type="text" class="form-control" id="firstName" placeholder="First Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="lastName">Last Name:</label>
<div class="col-xs-9">
<input type="text" class="form-control" id="lastName" placeholder="Last Name">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="phoneNumber">Phone:</label>
<div class="col-xs-9">
<input type="tel" class="form-control" id="phoneNumber" placeholder="Phone
Number">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Date of Birth:</label>
<div class="col-xs-3">
<select class="form-control">
<option>Date</option>
</select>
</div>
<div class="col-xs-3">
<select class="form-control">
<option>Month</option>
</select>
</div>
<div class="col-xs-3">
<select class="form-control">
<option>Year</option>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="postalAddress">Address:</label>
<div class="col-xs-9">
<textarea rows="3" class="form-control" id="postalAddress" placeholder="Postal
Address"></textarea>
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3" for="ZipCode">Zip Code:</label>
<div class="col-xs-9">
<input type="text" class="form-control" id="ZipCode" placeholder="Zip Code">
</div>
</div>
<div class="form-group">
<label class="control-label col-xs-3">Gender:</label>
<div class="col-xs-2">
<label class="radio-inline">
<input type="radio" name="genderRadios" value="male"> Male
</label>
</div>
<div class="col-xs-2">
<label class="radio-inline">
<input type="radio" name="genderRadios" value="female"> Female
</label>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-3 col-xs-9">
<label class="checkbox-inline">
<input type="checkbox" value="news"> Send me latest news and updates.
</label>
</div>
</div>
<div class="form-group">
<div class="col-xs-offset-3 col-xs-9">
<label class="checkbox-inline">
<input type="checkbox" value="agree"> I agree to the <a href="#">Terms and
Conditions</a>.
</label>
</div>
</div>
<br>
<div class="form-group">
<div class="col-xs-offset-3 col-xs-9">
<input type="submit" class="btn btn-primary" value="Submit">
<input type="reset" class="btn btn-default" value="Reset">
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
We can also add checkbox or radio button by applying the class input-group-
addon under the <span> element in the <div> element.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<div class="row">
<div class="col-xs-6">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox">
</span>
</div>
</div>
<div class="col-xs-6">
<div class="input-group">
<span class="input-group-addon">
<input type="radio">
</span>
</div>
</div>
</div>
</form>
<hr>
<form>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox">
</span>
</div>
<br>
<div class="input-group">
<span class="input-group-addon">
<input type="radio">
</span>
</div>
</form>
<script src="bootstrap-3.3.6-dist/js/jquery-2.2.0.min.js"></script>
<script src="bootstrap-3.3.6-dist/js/bootstrap.min.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<form>
<div class="row">
<div class="col-xs-6">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox">
</span>
</div>
</div>
<div class="col-xs-6">
<div class="input-group">
<span class="input-group-addon">
<input type="radio">
</span>
</div>
</div>
</div>
</form>
<hr>
<form>
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox">
</span>
</div>
<br>
<div class="input-group">
<span class="input-group-addon">
<input type="radio">
</span>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
In this code, we have added relative form sizing classes such as .input-
group-lg or .input-group-sm to the .input-group to make it larger or smaller.
There is no need for repeating the form control size classes on each element,
as all the contents in the .input-group will resize automatically.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Height Sizing of Bootstrap 3 Input Groups</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form>
<div class="row">
<div class="col-xs-4">
<div class="input-group input-group-lg">
<span class="input-group-addon"><span class="glyphicon glyphicon-
user"></span></span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-lg">
<span class="input-group-addon">
<input type="checkbox">
</span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-lg">
<div class="input-group-btn">
<button tabindex="-1" class="btn btn-default" type="button">Action</button>
<button tabindex="-1" data-toggle="dropdown" class="btn btn-default dropdown-
toggle" type="button">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
<input type="text" class="form-control">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-
user"></span></span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox">
</span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group">
<div class="input-group-btn">
<button tabindex="-1" class="btn btn-default" type="button">Action</button>
<button tabindex="-1" data-toggle="dropdown" class="btn btn-default dropdown-
toggle" type="button">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
<input type="text" class="form-control">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-4">
<div class="input-group input-group-sm">
<span class="input-group-addon"><span class="glyphicon glyphicon-
user"></span></span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<span class="input-group-addon">
<input type="checkbox">
</span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<div class="input-group-btn">
<button tabindex="-1" class="btn btn-default" type="button">Action</button>
<button tabindex="-1" data-toggle="dropdown" class="btn btn-default dropdown-
toggle" type="button">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
<input type="text" class="form-control">
</div>
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Height Sizing of Bootstrap 3 Input Groups</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<form>
<div class="row">
<div class="col-xs-4">
<div class="input-group input-group-lg">
<span class="input-group-addon"><span class="glyphicon glyphicon-
user"></span></span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-lg">
<span class="input-group-addon">
<input type="checkbox">
</span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-lg">
<div class="input-group-btn">
<button tabindex="-1" class="btn btn-default" type="button">Action</button>
<button tabindex="-1" data-toggle="dropdown" class="btn btn-default dropdown-
toggle" type="button">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
<input type="text" class="form-control">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-4">
<div class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-
user"></span></span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group">
<span class="input-group-addon">
<input type="checkbox">
</span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group">
<div class="input-group-btn">
<button tabindex="-1" class="btn btn-default" type="button">Action</button>
<button tabindex="-1" data-toggle="dropdown" class="btn btn-default dropdown-
toggle" type="button">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
<input type="text" class="form-control">
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-4">
<div class="input-group input-group-sm">
<span class="input-group-addon"><span class="glyphicon glyphicon-
user"></span></span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<span class="input-group-addon">
<input type="checkbox">
</span>
<input type="text" class="form-control">
</div>
</div>
<div class="col-xs-4">
<div class="input-group input-group-sm">
<div class="input-group-btn">
<button tabindex="-1" class="btn btn-default" type="button">Action</button>
<button tabindex="-1" data-toggle="dropdown" class="btn btn-default dropdown-
toggle" type="button">
<span class="caret"></span>
<span class="sr-only">Toggle Dropdown</span>
</button>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</div>
<input type="text" class="form-control">
</div>
</div>
</div>
</form>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
Button Styles
We can style the buttons using different classes available. It can be applied
to any element and is used for indicating differnet states.
In this code, we have applied the <button> and can be applied for <a>
and <input>
The different states indicated using the buttons are Default, Primary, Info,
Success, Warning, Danger, and Link.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Buttons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<button type="button" class="btn btn-default">Default</button>
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-link">Link</button>
<hr>
<input type="button" class="btn btn-default" value="Default">
<input type="button" class="btn btn-primary" value="Primary">
<input type="button" class="btn btn-info" value="Info">
<input type="button" class="btn btn-success" value="Success">
<input type="button" class="btn btn-warning" value="Warning">
<input type="button" class="btn btn-danger" value="Danger">
<input type="button" class="btn btn-link" value="Link">
<hr>
<a href="#" class="btn btn-default">Default</a>
<a href="#" class="btn btn-primary">Primary</a>
<a href="#" class="btn btn-info">Info</a>
<a href="#" class="btn btn-success">Success</a>
<a href="#" class="btn btn-warning">Warning</a>
<a href="#" class="btn btn-danger">Danger</a>
<a href="#" class="btn btn-link">Link</a>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
In this code, we have used the class .btn-block to create block level buttons
that spans the entire width of the parent element.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example of Bootstrap 3 Block Level Buttons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.css">
<!-- Optional Bootstrap theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
</head>
<body>
<button type="button" class="btn btn-primary btn-lg btn-block">Block level
button</button>
<button type="button" class="btn btn-default btn-lg btn-block">Block level
button</button>
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>
Bosstraap 63 lanjut 64