Bootstrap
Bootstrap
<div class="container-fluid">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link 1</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 2</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link 3</a>
</li>
</ul>
</div>
Vertical Navbar
• Remove the .navbar-expand-* class to create a
navigation bar that will always be vertical:
• Example
– <!-- A grey vertical navbar -->
<nav class="navbar bg-light">
...
</nav>
Centered Navbar
• Add the .justify-content-center class to center
the navigation bar:
• Example
• <nav class="navbar navbar-expand-sm bg-light
justify-content-center">
...
</nav>
Colored Navbar
• Use any of the .bg-color classes to change the
background color of the navbar (.bg-primary, .bg-
success, .bg-info, .bg-warning, .bg-danger, .bg-
secondary, .bg-dark and .bg-light)
• Tip: Add a white text color to all links in the
navbar with the .navbar-dark class, or use
the .navbar-light class to add a black text color.
• <nav class="navbar navbar-expand-sm bg-light
navbar-light">
Forms
• All textual <input> and <textarea> elements
with class .form-control get proper form
styling
<form action="/action_page.php">
<div class="mb-3 mt-3">
<label for="email" class="form-label">Email:</label>
<input type="email" class="form-
control" id="email" placeholder="Enter email" name="email">
</div>
<div class="mb-3">
<label for="pwd" class="form-label">Password:</label>
<input type="password" class="form-
control" id="pwd" placeholder="Enter password" name="pswd">
</div>
<div class="form-check mb-3">
<label class="form-check-label">
<input class="form-check-
input" type="checkbox“ name="remember"> Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Submit
</button>
</form>
Form Row/Grid (Inline Forms)
• If you want your form elements to appear side by side,
use .row and .col:
• <form>
<div class="row">
<div class="col">
<input type="text" class="form-
control" placeholder="Enter email" name="email">
</div>
<div class="col">
<input type="password" class="form-
control" placeholder="Enter password" name="pswd">
</div>
</div>
</form>
Disabled and Readonly
• Use the disabled and/or readonly attributes to
disable the input field:
• Example
• <input type="text" class="form-
control" placeholder="Normal input">
<input type="text" class="form-
control" placeholder="Disabled
input" disabled>
<input type="text" class="form-
control" placeholder="Readonly
input" readonly>
Color Picker
• To style an input with type="color" properly,
use the .form-control-color class:
• Example
• <input type="color" class="form-control form-
control-color" value="#CCCCCC">
• The .input-group class is a container to enhance an
input by adding an icon, text or a button in front or
behind the input field as a "help text".
• To style the specified help text, use the .input-group-
text class:
– <form>
<div class="input-group">
<span class="input-group-text">@</span>
<input type="text" class="form-
control" placeholder="Username">
</div>
<div class="input-group">
<input type="text" class="form-
control" placeholder="Your Email">
<span class="input-group-text">@example.com</span>
</div>
Checkboxes
• Checkboxes are used if you want the user to
select any number of options from a list of preset
options.
• Example
– <div class="form-check">
<input class="form-check-
input" type="checkbox" id="check1" name="option1"
value="something" checked>
<label class="form-check-label">Option 1</label>
</div>
Radio buttons
• Radio buttons are used if you want to limit the user to just
one selection from a list of preset options.
– <div class="form-check">
<input type="radio" class="form-check-
input" id="radio1" name="optradio" value="option1" checked>Opti
on 1
<label class="form-check-label" for="radio1"></label>
</div>
<div class="form-check">
<input type="radio" class="form-check-
input" id="radio2" name="optradio" value="option2">Option 2
<label class="form-check-label" for="radio2"></label>
</div>
<div class="form-check">
<input type="radio" class="form-check-input" disabled>Option 3
<label class="form-check-label"></label>
</div>
Custom Range
• To style a range menu, add the .form-range class to
the input element with type="range":
• Example
– <label for="customRange" class="form-label">Custom
range</label>
<input type="range" class="form-
range" id="customRange">
Tables
• A basic Bootstrap 5 table has a light padding and
horizontal dividers.
• The .table class adds basic styling to a table
<div class="container mt-3">
<h2>Basic Table</h2>
<p>The .table class adds basic styling (light padding and
horizontal dividers) to a table:</p>
<table class="table">
<thead>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Email</th>
</tr>
</thead>
• Striped Rows
– The .table-striped class adds zebra-stripes to a
table
• Bordered Table
– The .table-bordered class adds borders on all sides
of the table and cells
• Hover Rows
– The .table-hover class adds a hover effect (grey
background color) on table rows
• Black/Dark Table
– The .table-dark class adds a black background to
the table
• Dark Striped Table
– Combine .table-dark and .table-striped to create a
dark, striped table
• Hoverable Dark Table
– The .table-hover class adds a hover effect (grey
background color) on table rows
Class Description
.table-primary Blue: Indicates an important action
.table-success Green: Indicates a successful or positive action
.table-danger Red: Indicates a dangerous or potentially
negative action
.table-info Light blue: Indicates a neutral informative
change or action
.table-warning Orange: Indicates a warning that might need
attention
.table-active Grey: Applies the hover color to the table row
or table cell
.table-secondary Grey: Indicates a slightly less important action
.table-light Light grey table or table row background
.table-dark Dark grey table or table row background