Bootstrap
- The free and open-source CSS framework
- Contains HTML and CSS based design templates for buttons, forms, typography, navigation
- Supports JavaScript plugins
- Used to make faster and more responsive websites that are mobile-friendly
- Lightweight and has an extensive list of components
Bootstrap Cheat Sheet
Features of Bootstrap
- Very few or no cross-browser issues and incompatibilities
- Customizable and easy to use
- Powerful grid system
- Simple integration
- Good community support and documentation
- Pre-styled components
- Easy to learn and use
Bootstrap Alerts
Tag name |
Description |
Example |
alert-primary |
<div class="alert alert-primary" role="alert"> |
Text message to be displayed. |
alert-secondary |
<div class="alert alert-secondary" role="alert"> |
Text message to be displayed. |
alert-success |
<div class="alert alert-success" role="alert"> |
Success message to be displayed. |
alert-info |
<div class="alert alert-info" role="alert"> |
Info message to be displayed |
alert-warning |
<div class="alert alert-warning" role="alert"> |
Warning message to be displayed |
alert-danger |
<div class="alert alert-danger" role="alert"> |
Error message to be displayed, something really went wrong |
alert-light |
<div class="alert alert-light" role="alert"> |
Light font and style to display alert |
alert-dark |
<div class="alert alert-dark" role="alert"> |
Dark font and style to display alert message |
alert-link |
Add a link in the alert class <div class="alert alert-dark" role="alert"> |
I am an alert link |
alert-dismissible |
<div class="alert alert-info alert-dismissible"> can be used with any other alert class like info, success, danger etc for styling |
Alert message with dismissible (closing) link × |
alert-heading |
<h4 class="alert-heading">Alert success with heading</h4> can be used with any other alert class like info, success, danger etc for styling |
Alert success with heading |
Badges
badge |
Add badge, the same size of the previous (immediate) parent element by using em units and similar font size |
<h1>Heading text <span class="badge badge-secondary">Badge same size as heading text</span></h1> |
badge-pill |
used to make badges more rounded |
<span class="badge badge-pill badge-primary">Primary</span> |
badge-primary |
apply css styling corresponding to the primary badge <span class="badge badge-primary">Primary badge text variation</span> |
Primary badge text variation |
badge-secondary |
apply css styling corresponding to the secondary badge <span class="badge badge-primary">Secondary badge text variation</span> |
Secondary badge text variation |
badge-success |
styling to display badge indicating success |
Success badge |
badge-info |
styling to display badge indicating info |
Info badge |
badge-warning |
styling to display badge indicating warning |
Warning badge |
badge-danger |
styling to display badge indicating danger |
Danger badge |
badge-light |
styling to display badge indicating light background |
Light badge |
badge-dark |
styling to display badge indicating dark background |
Dark badge |
Breadcrumbs
breadcrumb |
indicate location of current page along with its navigation hierarchy separated through CSS separators using ::before and content <nav aria-label="breadcrumb"> |
Root / packages |
Recommended Course
Master Bootstrap 5 with 6 projects and Sass customization
Buttons
btn |
basic button feature |
<button type="button" class="btn">Basic</button> |
btn-primary |
display buttons with particular style for each class, for example, primary displays button with blue background |
<button type="button" class="btn-primary">Primary</button> |
btn-secondary |
displays button with grey background |
<button type="button" class="btn-secondary">secondary button</button> |
btn-success |
displays button with green background |
<button type="button" class="btn-success">Success</button> |
btn-info |
button with background for info – light blue |
<button type="button" class="btn-info">Info button</button> |
btn-warning |
yellow background for warning button |
<button type="button" class="btn-warning">Warning button</button> |
btn-danger |
red background for danger button |
<button type="button" class="btn-danger">Danger</button> |
btn-light |
light colored button |
<button type="button" class="btn-light">light button</button> |
btn-dark |
dark colored button (black) |
<button type="button" class="btn-dark">Dark button </button> |
btn-link |
button with link |
<button type="button" class="btn-link">link in button</button> |
btn-outline-primary |
Button with outline and text color same as the primary (blue) |
<button type="button" class="btn-outline-primary">Primary outline</button> |
btn-outline-secondary |
Button with outline and text color same as the secondary (grey) |
<button type="button" class="btn-outline-secondary">secondary outline</button> |
btn-outline-success |
Button with outline and text color same as the success (green) |
<button type="button" class="btn-outline- success "> success outline</button> |
btn-outline-info |
Button with outline and text color same as the info (light blue) |
<button type="button" class="btn-outline- info "> info outline</button> |
btn-outline-warning |
Button with outline and text color same as the warning (yellow) |
<button type="button" class="btn-outline- warning "> warning outline</button> |
btn-outline-danger |
Button with outline and text color same as the danger (red) |
<button type="button" class="btn-outline- danger "> danger outline</button> |
btn-outline-light |
Button with outline and text color same as the light (white) |
<button type="button" class="btn-outline-light">light outline and text</button> |
btn-outline-dark |
Button with outline and text color same as the secondary (black) |
<button type="button" class="btn-outline-dark">Dark outline</button> |
Button Groups
btn-group |
used to group series of buttons together |
<div class="btn-group"> |
btn-group-lg |
to create group of large buttons |
<div class="btn-group btn-group-lg">--individual button items</div> |
btn-group-sm |
to create group of small buttons |
<div class="btn-group btn-group-sm">--individual button items</div> |
btn-group-vertical |
to create group of vertically arranged buttons |
<div class="btn-group- vertical ">--individual button items</div> |
btn-group (nested) |
used to create dropdown menus. Use class dropdown-toggle, with data-toggle option as dropdown |
<div class="btn-group"> |
btn-toolbar |
to create multiple button groups side by side |
<div class="btn-toolbar" role="toolbar"> |
Button Modifiers
btn-lg |
to create button of larger size than the default size |
<button type="button" class="btn-primary btn-lg">Large</button> |
btn-sm |
to create button of size smaller than the default size |
<button type="button" class="btn-primary btn-sm">Small</button> |
btn-block |
To create full width buttons that occupy the entire horizontal row |
<button type="button" class="btn btn-primary btn-block">Full-Width Button</button> |
active button |
makes a button look like it is pressed |
<button type="button" class="btn btn-primary active">Active button with style of primary</button> |
disabled button |
button that cannot be clicked (is disabled) |
<button type="button" class="btn btn-warning" disabled>Disabled button</button> for a link (<a>), disabled has to be used in the class - class="btn btn-warning disabled” |
checkbox as button |
display checkboxes as buttons, same can be done with radio using the input type as radio. |
<div class="btn-group btn-group-toggle" data-toggle="buttons"> |
spinner buttons |
add spinner (the loading circle component) to a button |
<button class="btn btn-primary"> |
Cards
card |
card is like a business card having padding around the content. There are options for header, content, footer etc.. |
<div class="card"> |
card-body |
holds the content of the card |
<div class="card-body">Contents of the card</div> |
card-title |
The title of card that is displayed on top |
<h2 class="card-title">Title of card in h2</h2> |
card-subtitle |
Adds subtitle or quick small text |
<h6 class="card-subtitle">Card subtitle</h6> |
card-text |
Add lot of text and paragraphs to the card |
<p class="card-text">text.text.text</p> |
card-link |
To add a link to a card; multiple links can be added |
<a href="#!" class="card-link">link in the card</a> |
card-img-top |
the main card image shown on the top |
<img class="card-img-top" src="myimpimage.png"> |
middle image |
To display an image in the middle, no need to specify card image class as top or bottom, just add the image tag. |
<img src="myimpimage.png"> |
card-img-bottom |
display image after the card content |
<img class="card-img-bottom" src="myimpimage.png"> |
card-img-overlay |
To display image in the background. Can contain text over it. |
<div class="card-img-overlay"> |
list-group |
list of items in a card |
<ul class="list-group"> |
card-header |
add header for a card |
<div class="card-header"> |
h*.card-header |
card header with particular heading size, h1-h6 |
<h3 class="card-header">Card header in h3</h3> |
card-footer |
footer for the card |
<div class="card-footer"> |
card-group |
contains multiple cards side by side without any margins |
<div class="card-group"> …card 1 div tags |
card-deck |
creates cards side by side with margins. All cards are of equal size (height and width) |
<div class="card-deck"> …card 1 div tags |
card-columns |
cards are displayed as a grid with rows and columns that adjust automatically as cards are added or removed |
<div class="card-columns"> …card 1 div tags |
card bg-... text-... |
used to style the cards by formatting with different colors for text and background |
<div class = "card text-<color> bg-<color>"> |
Carousel
Adds slide show for going through elements in a cyclic fashion
carousel slide |
adds animation and CSS transition effect while moving from one slide to next. |
<div class="carousel slide" data-ride="carousel"> |
carousel-fade |
adds a fading effect when slide changes from one to next |
<div class="carousel slide carousel-fade" data-ride="carousel"> |
carousel-inner |
contains individual slides to the carousel |
<div class="carousel-inner"> |
carousel-item |
Add an individual item (slide) to the carousel. The current (first) item is marked as active |
<div class="carousel-item"> |
carousel-indicators |
indicates the number of slides, current slide being shown as dots/bars at the bottom of the carousel |
<ul class="carousel-indicators"> |
carousel-caption |
Adds caption for individual slides (carousel-item) |
<div class="carousel-caption"> |
carousel-control-prev |
left control |
<a class="carousel-control-prev" href="#demo" data-slide="prev"></a> |
carousel-control-next |
right control |
<a class="carousel-control-next" href="#demo" data-slide="prev"></a> |
Collapse
collapse |
provides basic expand/collapse functionality |
<p> |
accordion |
accordion collapsible format using the card component |
<div id="accordion"> |
Dropdowns
dropdown |
Allows users to choose one value out of the many options. Dropdown can be a button or link. To add a down-arrow, use the caret class – <span class="caret"> |
<div class="dropdown"> and then in the button or link definition, add data-toggle="dropdown" attribute |
dropdown (split) |
To show the dropdown menu with proper spacing around the caret. The caret is centred between the button (or link) and the dropdown menu when expanded. Use “dropdown-toggle dropdown-toggle-split” along with the button or link class. |
|
dropup |
Same functionality as dropdown except the caret is pointed up and menu is shown above the button or link. |
Use the div class as ‘dropup’ and data-toggle = “dropdown” |
dropup (split) |
Same as dropdown (split) but with menus shown above. The caret is centred between the button/link and the menu items shown when expanded. |
|
dropright |
to display the dropdown menu on the right side. Add <div class="dropdown dropright"> and then in the menu list element, x-placement="right-start" |
|
dropleft |
Display the dropdown menu on the left side. <div class="dropdown dropleft"> |
|
dropdown-header |
To add headers inside the menu list. This is useful when we divide the dropdowns in categories. Add header as another list element – <li class="dropdown-header">Dropdown header A</li> |
|
dropdown-item-text |
Add plain text to a dropdown item; can be used as text on links too by adding href |
<span class="dropdown-item-text">Plain Text</span> |
dropdown-divider |
creates a thin horizontal border between links to separate them. Just add the class wherever the divider is required on the list. <div class="dropdown-divider"></div> |
|
dropdown-item disabled |
To disable any action on a particular dropdown item; use the class “dropdown-item disabled” on the particular item |
|
dropdown-item-active |
To make the particular dropdown item active by making the background blue. Add the class “dropdown-item active” to the particular item |
|
dropdown-menu-right |
right align the drop-down menu |
<div class="dropdown-menu dropdown-menu-right"> |
Forms
form-group |
creates a stacked form with proper margins when added as a wrapper around each input type or form control |
<div class="form-group"> |
form-inline |
all elements are inline and left-aligned |
<form class="form-inline" action="someactionpage.jsp"> |
form using the grid |
use rows and columns inside form |
<form> |
form-control |
default class for styling <input>, <select> and <textarea> elements |
<input type="password" class="form-control" …. |
form-control-lg |
large size form area |
<input type="password" class="form-control-lg" …. |
form-control-sm |
small size form area |
<input type="password" class="form-control-sm" …. |
form-control-file |
form control to upload file |
<input type="file" class="form-control-file" id="formcontrolfileupload"> |
form-control-plaintext |
to have read only contents in the form without losing the styling |
<input type="text" readonly class="form-control-plaintext" id="defaulttext" value="someexample@gmail.com"> |
form-control-range |
to include range element |
<input type="range" class="form-control-range"> |
form-check |
to create a checkbox input |
<div class="form-group form-check"> |
form-check-inline |
to create checkboxes side by side <div class="form-check form-check-inline"> |
|
disabled items |
Add items that cannot be clicked; are disabled (greyed out) |
<fieldset disabled> |
readonly |
adds read only text |
<input class="form-control" type="text" placeholder="I am a read only text" readonly> |
Form input groups
input-group |
container that enhances an input field by adding button, text or icon before or after the field to help the user. |
<div class="input-group"> |
input-group-prepend |
add a help text before the input field |
<div class="input-group-prepend"> |
input-group-append |
add a help text after the input field |
<div class="input-group-append"> |
input-group-sm |
for small input groups |
<div class="input-group input-group-sm"> |
input-group-lg |
for large input groups |
<div class="input-group input-group-lg"> |
checkbox |
add check box before or after input field |
<div class="input-group"> |
radio |
add radio button before or after input field |
<div class="input-group"> |
dropdown |
add dropdown before or after input field |
<div class="input-group"> |
Custom Forms
custom-checkbox |
create custom checkboxes |
<form> |
custom-radio |
create custom radio buttons |
<form> |
custom-switch |
create custom toggle switch |
<div class="custom-control custom-switch"> |
custom-select |
create custom select options |
<select class="custom-select"> |
custom-file |
display custom file upload option |
<div class="custom-file"> |
custom-range |
create a custom range menu with rectangle pointer and bar |
<form> |
Grid
container |
container for the grid |
<div class="container">content</div> |
container-fluid |
fluid container for full-width |
<div class="container-fluid">full-width container</div> |
row |
row elements of the grid |
<div class="row"> |
col-# ( <576px) |
column with specified width |
<div class="col-2"> ... |
col-sm-# ( ≥576px) |
small columns with specified width |
<div class="col-sm-2"> |
col-md-# ( ≥768px) |
medium column |
<div class="col-md-2"> |
col-lg-# ( ≥992px) |
large column |
<div class="col-lg-2"> |
col-xl-# ( ≥1200px) |
extra large column |
<div class="col-xl-2"> |
col |
equal size column |
<div class="col"> |
col-* |
equal width columns – col-sm, col-md, col-lg, col-xl |
<div class="col-xl"> |
no-gutters |
remove horizontal padding between columns and margins between rows |
<div class="row no-gutters">… column definitions</div> |
offset-*-# |
small, medium, large or extra large offsets with size |
<div class="col-3 offset-6"> |
order-# |
order in which the column should appear |
<div class="col order-md-2">Ordered column</div> |
nested columns |
columns inside column |
<div class="row"> |
Images
img-fluid |
display image and adjust size automatically |
<img src="/images/drawing.png" class="img-fluid" alt="Your dynamic image"> |
img-thumbnail |
represents thumbnail image |
<img class="img-thumbnail" src="/images/drawing.png" alt="Thumbnail image"> |
Jumbotron
jumbotron |
big box created to give extra focus on some special information or text. you can put any valid HTML elements inside jumbotron |
<div class="jumbotron"> |
jumbotron-fluid |
full-width jumbotron occupying the whole horizontal space without displaying the rounded borders |
<div class="jumbotron jumbotron-fluid"> |
List Group
list-group |
display an unordered list with items |
<ul class="list-group"> |
list-group-item active |
highlight the active item |
<li class="list-group-item active">Active item</li> |
list-group-item disabled |
highlight the disabled item |
<li class="list-group-item disabled">disabled list item</li> |
list-group-item-action |
create list of linked items using the <div> class and <a> in place of <ul> and <li> |
<div class="list-group"> |
list-group-item-primary |
color list items using the color code of the contextual class primary |
<li class="list-group-item list-group-item-primary">Primary color </li> |
list-group-item-secondary |
color list items using the color code of the contextual class secondary |
<li class="list-group-item list-group-item-secondary">secondary color </li> |
list-group-item-success |
color list items using the color code of the contextual class success |
<li class="list-group-item list-group-item-success">success color </li> |
list-group-item-info |
color list items using the color code of the contextual class info |
<li class="list-group-item list-group-item-info">Info color </li> |
list-group-item-warning |
color list items using the color code of the contextual class warning |
<li class="list-group-item list-group-item-warning">Warning color </li> |
list-group-item-danger |
color list items using the color code of the contextual class danger |
<li class="list-group-item list-group-item-danger">Danger color </li> |
list-group-item-light |
colour list items using the color code of the contextual class light |
<li class="list-group-item list-group-item-light">Light color </li> |
list-group-item-dark |
colour list items using the color code of the contextual class dark |
<li class="list-group-item list-group-item-dark">Dark color </li> |
list-group with badges |
Add badge to list item |
<li class="list-group-item"> |
list-group with d-flex |
full-width box for list items |
<li class="list-group-item d-flex justify-content-between align-items-center"> |
list-group-horizontal |
create horizontal list items |
<ul class="list-group list-group-horizontal"> |
list-group-flush |
remove borders and rounded corners |
<ul class="list-group list-group-flush"> |
Media objects
media |
provides easy way to align media objects along with content. Used for social media objects like tweets, blog post comments etc… |
<div class="media"> |
nested media |
achieved by placing a new media container inside the .media-body container |
<div class="media"> |
d-flex align-self-start |
top alignment |
<img src="img_1.png" class="align-self-start mr-3" style="width:60px"> |
d-flex align-self-center |
middle alignment |
<img src="img_1.png" class="align-self-center mr-3" style="width:60px"> |
d-flex align-self-end |
bottom alignment |
<img src="img_1.png" class="align-self-end mr-3" style="width:60px"> |
right aligned media |
right alignment of media object i.e. text on left and image on right side – just move the img tag after the div tag |
<div class="media"> |
Modal
modal |
to open a modal dialog window on the current page based on user event |
-- open the modal dialog on button click |
modal-dialog-centered |
open modal dialog in the center of page |
<div class="modal-dialog modal-dialog-centered"> |
modal-dialog-scrollable |
to add a scroll bar to the modal window |
<div class="modal-dialog modal-dialog-scrollable"> |
modal fade |
add fading effect while opening or closing the modal box |
<div class="modal fade"></div> |
modal-lg |
large size modal |
<div class="modal-dialog modal-lg"> |
modal-sm |
small sized modal |
<div class="modal-dialog modal-sm"> |
modal-xl |
extra-large size modal box |
<div class="modal-dialog modal-xl"> |
Navs
ul.nav |
create horizontal menus by adding .nav class to the ul element and then add .nav-item for individual li items. Add links using .nav-link |
<ul class="nav"> … other nav links |
nav.nav |
create horizontal menus in the nav element itself |
<nav class="nav"> |
nav justify-content-* |
justify navigation content to the end (right) or center |
<ul class="nav justify-content-center"> |
nav flex-column |
create vertical navigation |
<ul class="nav flex-column"> |
nav-tabs |
make the active nav as a tab |
<ul class="nav nav-tabs"> |
nav-pills |
shows the navigation menu as navigation pills. You can toggle the pills using data-toggle = “pills” option |
<ul class="nav nav-pills"> |
nav-fill |
use .nav-fill to fill the available space proportionately. Can be used on pills or tabs |
<ul class="nav nav-pills nav-fill"> |
nav-justified |
justify the pills or tabs using this option (all equal width tabs or pills) |
<ul class="nav nav-pills nav-justified"> |
nav-tabs with dropdown |
Creates tabs with dropdown menu alongside other navigation items |
<ul class="nav nav-tabs"> ... code for dropdown |
nav-pills with dropdown |
Creates pills with dropdown menu alongside other navigation items |
<ul class="nav nav-pills"> |
Navbar
navbar |
navigation header placed at the top of a webpage |
<ul class="navbar-nav"> |
navbar-brand |
used to highlight a brand, main project or logo of the page |
<a class="navbar-brand" href="#">Brand</a> |
navbar with form |
add form controls in a navigation bar |
<nav class="navbar navbar-expand-md bg-primary navbar-dark"> |
navbar-text |
to add navbar text |
<span class="navbar-text"> |
navbar-dark bg-dark |
add navigation bar with dark background; other possibilities are primary, secondary, success, light, warning, danger, info |
<nav class="navbar navbar-dark bg-dark"> |
navbar-light |
navigation bar with light background |
<nav class="navbar navbar-light"></nav> |
navbar fixed-top |
nav bar that is fixed on top of the page |
<nav class="navbar fixed-top navbar-dark"> |
navbar fixed-bottom |
nav bar that is fixed on bottom of the page |
<nav class="navbar fixed-bottom navbar-light"> |
navbar sticky-top |
sticks to the top of the page when scrolled over |
<nav class="navbar sticky-top navbar-light"> |
collapse navbar-collapse |
collapse navigation bars and display only when clicked. Useful for small screens like mobile devices |
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar"> |
navbar-toggler |
used to add expand/collapse functionality to navbar |
<button class="navbar-toggler" type="button" |
navbar-expand-* |
responsive collapsing class – to stack the navbar vertically as per size (* - sm, md, lg, xl) |
<nav class="navbar navbar-expand-sm bg-dark"> |
Pagination
pagination |
add basic pagination to display only certain records on one page |
<ul class="pagination"> |
page-item disabled |
to disable a particular page number or item from being clicked |
<li class="page-item disabled"> |
page-item active |
to indicate the currently active page item |
<li class="page-item active"><a class="page-link" href="#">3</a></li> |
pagination-lg |
display larger size pagination blocks |
<ul class="pagination pagination-lg"> |
pagination-sm |
display smaller size pagination blocks |
<ul class="pagination pagination-sm"> |
Popover
popovers |
display popover text on click (similar to tooltip). Popover position can be set using the data-placement attribute, data-placement = top/bottom/left/right Text is closed when the box is clicked again |
<a href="#" title="mypopoverdata" data-toggle="popover" data-placement="top" data-content="Content">click me to see details</a> |
dismissible popover |
to close the popover text when user clicks outside the element anywhere in the document |
<a href="#" title="Dismissible popover" data-toggle="popover" data-trigger="focus" data-content="Click anywhere to close the popover">Click</a> |
hover popover |
display popover when user moves the mouse pointer over the element |
<a href="#" title="Header" data-toggle="popover" data-trigger="hover" data-content="content">Hover over me to see popover content</a> |
Progress
progress |
class to add a progress element to the container |
<div class="progress"> |
progress-bar |
the main element for progress bar |
<div class="progress-bar" role="progressbar" style="width: 41%"</div> |
progress-bar with label |
to show a visible percentage (or some text) in the progress bar |
<div class="progress-bar" style="width:70%">progress details</div> |
progress-bar with height |
to change the default value, add the css property height. Default value is 16px |
<div class="progress-bar" style="width:60%;height:12px"></div> |
progress-bar bg-* |
color for the progress bar. Can be primary, secondary, dark, light, info, success, warning, danger |
<div class="progress"> <div class="progress-bar bg-secondary" role="progressbar" style="width: 30%" aria-valuenow="25"</div> </div> |
multiple progress-bar |
progress bars can be stacked one after other horizontally inside the same “progress” class. |
<div class="progress"> |
progress-bar-striped |
add a striped progress bar |
<div class="progress-bar progress-bar-striped" style="width:30%"></div> |
progress-bar-striped bg-* |
striped progress bar with background color |
<div class="progress-bar progress-bar-striped bg-success" role="progressbar" style="width: 40%"</div> |
progress-bar-animated |
animated progress bar |
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 20%"></div> |
Scrollspy
data-spy |
Used to automatically update the links of a navigation list depending on the scroll position |
data-spy="scroll" should be added to the element, usually <body> that needs to be used as a scrollable area. |
Spinner
spinner-border |
create a spinner (loader) |
<div class="spinner-border" role="status"> |
spinner-border text-* |
spinner with specific styling. * can be primary, secondary, info, success, warning, danger, dark, light |
<div class="spinner-border text-primary" role="status"> |
spinner-border-sm |
small size spinner |
<div class="spinner-border spinner-border-sm" role="status"> |
spinner-grow |
spinner that grows and shrinks alternately |
<div class="spinner-grow" role="status"> |
spinner-grow text-* |
growing spinners in different colors – primary, secondary etc… |
<div class="spinner-grow text-primary" role="status"> |
spinner-grow-sm |
small sized growing spinners |
<div class="spinner-grow spinner-grow-sm" role="status"> |
Tables
table |
to add basic table |
<table class="table">…table contents</table> |
thead-light |
light header background for the table header (<th>) |
<thead class="thead-light"> |
thead-dark |
dark header background for the table header (<th>) |
<thead class="thead-dark"> |
table-striped |
striped table background with alternate dark and light (zebra) |
<table class="table table-striped"> |
table-bordered |
bordered (ruled) table |
<table class="table table-bordered"> |
table-borderless |
table without any borders |
<table class="table table-borderless"> |
table-hover |
adds hover effect (dark background on mouse hover) |
<table class="table table-hover"> |
table-sm |
small size table |
<table class="table table-sm"> |
table-*-responsive |
responsive tables; a horizontal scrollbar is added for small screens (<992px) if required can be sm,md,lg or xl |
<table class="table table-sm-responsive"><!-- ... table content --></table> |
table-reflow |
||
table-active |
contextual class active indicates active row in grey |
<tr class="table-active"> |
table-primary |
contextual class primary adds blue background to table |
<tr class="table-primary"> |
table-secondary |
contextual class secondary adds specific color background to table |
<tr class="table-secondary"> |
table-success |
contextual class success adds green color background to table |
<tr class="table-success"> |
table-info |
contextual class info adds specific blue background to table |
<tr class="table-info"> |
table-warning |
contextual class warning adds yellow color background to table |
<tr class="table-warning"> |
table-danger |
contextual class danger adds specific red/pink background to table |
<tr class="table-danger"> |
table-light |
contextual class secondary adds light (white) background to table |
<tr class="table-light"> |
table-dark |
contextual class secondary adds dark (grey/black) background to table |
<tr class="table-dark"> |
Toasts
toast |
a quick alert box that appears only for a few seconds when any user event happens (button click, form submit etc…). contains of two parts – header and body |
<div class="toast"> <div class="toast-body"> |
Tooltips
tooltip |
small popup box that appears when user hovers the mouse over an element (moves the mouse lightly without clicking) |
<a href="#" data-toggle="tooltip" data-placement="auto" title="Good day!">Thanks for hovering</a> |
Typography
display-# (1-4) |
display heading of different sizes from 1-4, with larger font size and crispier font weight than the normal headings |
<h1 class="display-1">Display 1</h1> |
lead |
make a paragraph to stand out from others |
<p class="lead">This paragraph stands out amongst others</p> Result - This paragraph stands out amongst others |
blockquote |
used to quote blocks of text from a different source |
<blockquote class="blockquote"> |
blockquote-footer |
footer for the blockquote text |
<footer class="blockquote-footer">Footer text</footer> |
list-unstyled |
removes default list style and the left margin from the immediate child list items |
<ul class="list-unstyled"> |
list-inline |
place all the list items in a single line |
<ul class="list-inline"> |
dl-horizontal |
definition list. Contains <dt> and <dd> elements. dl-horizontal makes terms and descriptions stand side-by-side |
<dl class = "dl-horizontal"> |
mark |
highlight a text with yellow background and some padding using mark element |
<mark>highlight text</mark> |
abbr |
style the element with dotted border bottom |
<abbr>ABC</abbr> |
code |
the code snippets are embedded in the code element. |
<code>span</code> |
kbd |
display keyboard inputs with black background (with specific styling) |
<kbd>ctrl + c</kbd> |
Utility: Borders
border |
to add border to a text |
<span class="border border-dark">Hi there</span> |
border-*-0 |
border-0 represents no border. Variations – border-top-0 represents no border on top, same way bottom, right and left are possible |
<span class="p-1 border border-primary border-0">I have no border</span> |
border-* |
coloured border based on contextual classes. Possible values – primary, secondary, success, danger, warning, info, light, dark, white |
<span class="border border-primary">I have blue border</span> |
rounded |
refers to rounded image border |
<img class="rounded" src="/images/myimg.png"> |
rounded-sm |
small rounded edges |
<img class="rounded-sm" src="/images/myimg.png"> |
rounded-lg |
large rounded edges |
<img class="rounded-lg" src="/images/myimg.png"> |
rounded-circle |
rounded circular image |
<img class="rounded-circle" src="/images/myimg.png"> |
rounded-0 |
no rounding (sharp edges) |
<img class="rounded-0" src="/images/myimg.png"> |
rounded-* |
rounded from 2 sides on left, right, top or bottom |
<img class="rounded-top" src="/images/myimg.png"> |
Utility: Colors
bg-primary |
use blue background |
<div class="bg-primary text-white">text is white and background is blue</div> |
bg-secondary |
use grey background |
<div class="bg-secondary"> background is grey</div> |
bg-success |
use green background |
<div class="bg-success"> background is green</div> |
bg-info |
use light blue background |
<div class="bg-info"> background is light blue</div> |
bg-warning |
use yellow background |
<div class="bg-warning"> background is yellow</div> |
bg-danger |
use red background |
<div class="bg-danger"> background is red</div> |
bg-light |
use light (white or light grey) background |
<div class="bg-light"> background is white/light grey</div> |
bg-dark |
use black (dark) background |
<div class="bg-dark"> background is black</div> |
bg-white |
use white background |
<div class="bg-white"> background is white</div> |
text-* |
use specific colors for the text. Values can be primary, secondary, success, info, warning, danger, light, dark, white |
<p class="text-primary">Text color is blue</p> |
Utility: Display
d-*-block |
display block with specific styling |
<span class="d-block bg-primary">display block</span> |
d-*-flex |
display flex items with specific styling |
<div class="d-flex bg-secondary">...</div> |
d-*-inline |
inline display with specific styling |
<div class="d-inline bg-secondary">...</div> |
d-*-inline-block |
display inline block |
<div class="d-inline-block bg-secondary">...</div> |
d-*-inline-flex |
styling for inline flex |
<div class="d-inline-flex bg-secondary">...</div> |
d-*-none |
hide display for certain element (same as display: none) |
<div class="d-none">...</div> |
d-*-table |
display styling for table |
<div class="d-table">...</div> |
d-*-table-cell |
styling for table cell |
<div class="d-table-cell">...</div> |
d-print-... |
controls how elements have to be displayed while printing. Value can be none, block, inline, inline-block, table, table-row,table-cell, flex, inline-flex |
<div class="d-print-block">Display content as block on print</div> |
Utility: Flexbox
flex-*-column |
flex column to display content vertically (top to bottom). Responsive variations are sm,md,lg,xl |
<div class="d-flex flex-column"> <!--default size--> |
flex-*-column-reverse |
reverse the order of display of columns |
<div class="d-flex flex-column-reverse"> |
flex-*-row |
display content horizontally one after the other (side-by-side). Responsive variations are sm,md,lg,xl |
<div class="d-flex flex-row"> |
flex-*-row-reverse |
reverse the order of display of rows |
<div class="d-flex flex-row-reverse"> |
flex-*-nowrap |
default setting to display text in the flex container |
<div class="d-flex flex-nowrap">..</div> |
flex-*-wrap |
add wrap functionality. Responsive variations – sm, ml, lg, xl |
<div class="d-flex flex-wrap"> ... </div> |
flex-*-wrap-reverse |
reverse order display. |
<div class="d-flex flex-wrap-reverse"> ... </div> |
flex-fill |
fill the background with different colors – primary, secondary, info etc… |
<div class="p-2 flex-fill bg-*">Flex item</div> |
flex-*-grow-1 |
lets the specified element take the entire available space. |
<div class="p-2 flex-grow-1 bg-primary">Flex grow</div> |
flex-*-grow-0 |
don’t let the items grow on different screens |
<div class="p-2 flex-grow-0 bg-info">dont let me grow</div> |
flex-*-shrink-1 |
lets the item shrink |
<div class="p-2 flex-shrink-1 bg-danger">Flex shrink</div> |
flex-*-shrink-0 |
no shrinking on different screens |
<div class="p-2 flex-shrink-0 bg-primary">Flex no shrink</div> |
justify-content-*-start |
change the alignment of the items (justify to left) |
<div class="d-flex justify-content-start"> |
justify-content-*-end |
justify to the end (right) |
<div class="d-flex justify-content-end"> |
justify-content-*-center |
center justify the items |
<div class="d-flex justify-content-center"> |
justify-content-*-between |
justify between the items |
<div class="d-flex justify-content-between"> |
justify-content-*-around |
justify space around the items |
<div class="d-flex justify-content-around"> |
align-content-*-start |
control vertical alignment to start (default) |
<div class="d-flex flex-wrap align-content-start"> |
align-content-*-end |
align content to end |
<div class="d-flex flex-wrap align-content-end"> |
align-content-*-center |
align content to the center |
<div class="d-flex flex-wrap align-content-center"> |
align-content-*-around |
align space around items |
<div class="d-flex flex-wrap align-content-around"> |
align-content-*-stretch |
stretch individual flex box items |
<div class="d-flex flex-wrap align-content-stretch"> |
align-items-*-baseline |
align items with respect to baseline |
<div class="d-flex flex-wrap align-items-baseline"> |
align-items-*-stretch |
stretch items to full width of flex container |
<div class="d-flex align-items-stretch"> |
align-self-*-start |
self-align individual flex item to start (default) |
<div class="align-self-start">flex item align</div> |
align-self-*-end |
self-align individual flex item to end |
<div class="align-self-end">flex item align</div> |
align-self-*-center |
self-align individual flex item to center |
<div class="align-self-center">flex item align</div> |
align-self-*-baseline |
self-align individual flex item to baseline |
<div class="align-self-baseline">flex item align</div> |
align-self-*-stretch |
stretch to full width |
<div class="align-self-stretch">flex item align</div> |
order-*-# |
change the order of display of particular flex items from 0-12 |
<div class="order-12">first item</div> <!--will be displayed 12th--> |
Utility: Misc
close |
to display close option |
<button type="button" class="close"> |
embed-responsive |
embed a responsive media of particular size |
<div class="embed-responsive embed-responsive-24by16"> |
shadow-none |
background without shadow and with specific css styling properties |
<div class="shadow-none p-2 mb-5 bg-dark rounded">No shadow</div> |
shadow-sm |
small shadow |
<div class="shadow-sm p-2 mb-5 bg-light rounded">Small Shadow</div> |
shadow |
regular shadow option |
<div class="shadow p-2 mb-5 bg-light rounded">Default shadow setting</div> |
shadow-lg |
large shadow |
<div class="shadow-lg p-2 mb-5 bg-white">Larger shadow</div> |
invisible |
to mark an element as invisible |
<div class="invisible">invisible element</div> |
visible |
mark an element as visible |
<div class="visible">visible element</div> |
sr-only |
show a particular element on screen readers only |
<span class="sr-only">Hide me everywhere except screen readers</span> |
stretched-link |
make the containing block of a link clickable by using stretched-link. Can be used on card, media etc… |
<a href="#" class="stretched-link">stretch the link to container</a> |
Utility: Positioning
align-* |
align at baseline, top, bottom, middle, text-top, text-bottom |
example – |
clearfix |
used to clear floats left and right. Used when the screen is wide or small |
<div class="clearfix"> |
fixed-top |
make any element stay on the top of the page independent of scrolling |
<nav class="fixed-top">Fixed on page top</nav> |
fixed-bottom |
make any element stay on the bottom of the page independent of scrolling |
<nav class="fixed-bottom">Fixed on page bottom</nav> |
sticky-top |
can be anywhere on the page, but when scrolled past, stays at top of the page |
<div class="sticky-top">Sticks on top</div> |
float-*-left |
float left on the screen; * can be sm, md, lg, xl |
<div class="float-sm-left">Float left on views small or wider</div> |
float-*-right |
float right on the screen; * can be sm, md, lg, xl |
<div class="float-md-right">Float right on views small or wider</div> |
float-*-none |
no floating for the particular viewport |
<div class="float-lg-none">no float on views small or wider</div> |
Utility: Sizing
w-* |
specified width of a div tag; can be any percentage upto 100% |
<div class="w-25 p-3" style="background-color: blue">Width 25% and size 3</div> |
h-* |
customized height for div tag |
<div class="h-50 d-inline-block" style="background-color: red">Height is 50%</div> |
mw-* |
maximum width |
<div class="mw-100 bg-success">Max Width 100%</div> |
mh-* |
maximum height |
<div class="mw-75 bg-success">Max height 75%</div> |
Utility: Spacing
m-1 / m-*-# |
spaced div tags with margin on all sides; star ranges from 0 space to 6 spaces |
<div class="m-4 bg-success d-inline-block">div with 4 spaces</div> |
mt-1 / mt-*-# |
margin on top |
<div class="mt-3 bg-warning d-inline-block">Spaced top margin</div> |
mr-1 / mr-*-# |
margin on right |
<div class="mr-3 bg-warning d-inline-block">Spaced right margin</div> |
mb-1 / mb-*-# |
bottom margin |
<div class="mb-3 bg-warning d-inline-block">Spaced bottom margin</div> |
ml-1 / ml-*-# |
left margin |
<div class="ml-3 bg-warning d-inline-block">Spaced left margin</div> |
mx-1 / mx-*-# |
left and right (x-axis) margin |
<div class="mx-3 bg-primary d-inline-block">Spaced x axis margin</div> |
my-1 / my-*-# |
top and bottom (y-axis) margin |
<div class="my-3 bg-primary d-inline-block">Spaced y axis margin</div> |
m-n1 / m-*-n# |
negative spacing (change of direction) – can be any of the above – left, right, top, bottom, x, y |
<div class="m-n5 bg-primary d-inline-block">Negative spacing</div> |
p-1 / p-*-# |
padding on all sides |
<div class="p-3 bg-danger d-inline-block">Padding on all sides with box size 3</div> |
pt-1 / pt-*-# |
padding on top |
<div class="pt-3 bg-danger d-inline-block">Padding on top with box size 3</div> |
pr-1 / pr-*-# |
padding on right |
<div class="pr-3 bg-danger d-inline-block">Padding on right with box size 3</div> |
pb-1 / pb-*-# |
padding on bottom |
<div class="pb-3 bg-danger d-inline-block">Padding on bottom with box size 3</div> |
pl-1 / pl-*-# |
padding on left |
<div class="pl-3 bg-danger d-inline-block">Padding on left with box size 3</div> |
px-1 / px-*-# |
padding on left and right (x-axis) |
<div class="px-3 bg-danger d-inline-block">Padding on left and right with box size 3</div> |
py-1 / py-*-# |
padding on top and bottom (y-axis) |
<div class="py-3 bg-danger d-inline-block">Padding on top and bottom with box size 3</div> |
Utility: Text
font-weight-bold |
to write text in bold |
<p class="font-weight-bold">Text in bold</p> |
font-weight-bolder |
bolder than bold |
<p class="font-weight-bolder">Bolder text</p> |
font-weight-light |
light text, lighter than the normal text weight |
<p class="font-weight-light">Light text</p> |
font-weight-lighter |
lighter than light text weight |
<p class="font-weight-lighter">Lighter than light</p> |
font-weight-normal |
normal text |
<p class="font-weight-normal">Normal weight </p> |
text-decoration-none |
no text decoration |
<p class="text-decoration-none">No decorations on text</p> |
font-italic |
text in italic |
<p class="font-italic">Italic text (Ctrl+i) in word</p> |
text-monospace |
text in monospace |
<p class="text-monospace">monospace text</p> |
text-justify |
justified text; justify can be left, right, center |
<p class="text-justify">This is a justified text</p> |
text-nowrap |
text without word wrapping |
<p class="text-nowrap">No wrapping</p> |
text-*-left |
text-sm-left, text-md-left, text-lg-left, text-xl-left where sm = small, md= medium, lg = large, xl = extra large |
<p class="text-sm-left">Left align text on viewports that are SM (small) or wider.</p> |
text-*-right |
text-sm- right, text-md- right, text-lg- right, text-xl- right where sm = small, md= medium, lg = large, xl = extra large |
<p class="text-md-right">right align text on viewports that are md (medium) or wider.</p> |
text-*-center |
text-sm- center, text-md- center, text-lg- center, text-xl- center where sm = small, md= medium, lg = large, xl = extra large |
<p class="text-lg-center">center align text on viewports that are lg (large) or wider.</p> |
text-lowercase |
lowercase letters |
<p class="text-lowercase">text in lowercase</p> |
text-uppercase |
uppercase letters |
<p class="text- uppercase">text in uppercase </p> |
text-capitalize |
Capitalize Each Word in the comprising text |
<p class="text-capitalize">capitalized each word</p> |
text-truncate |
truncate the comprising text with an ellipsis at block or inline level |
<p class="text-truncate">truncate this text while displaying because its long</p> |
text-body |
display text in default settings |
<p class="text-body">Default way of displaying text</p> |
text-black-50 |
lighter than normal text (50% opaque black). |
<p class="text-black-50">Text that's 50% opaque</p> |
text-white-50 |
white text that is 50% opaque in appearance |
<p class="text-white-50">Text that's 50% opaque white</p> |
text-muted |
contextual class to display muted text. <p class="text-muted">Muted text.</p> |
Muted text. Muted link. |
text-hide |
Swap the text of heading tags with a background image |
<h1 class="text-hide">Hide this text and show background image</h1> |
text-break |
set overflow wrap so that long text doesn’t break the layout of a component |
<p class="text-break">very very long text, that needs to be wrapped to maintain alignment</p> |
People are also reading: