container
: add to <div>
for fixed width containercontainer-fluid
: add to <div>
for full width containercontainer-sm|md|lg|xl
: add to <div>
for responive containers<div class="container"> ... </div>
jumbotron
: add to <div>
for indicate big grey box for calling extra attentionjumbotron-fluid
: add to <div>
for full-width jumbotron without rounded borders<div class="jumbotron">
<h1>Bootstrap Tutorial</h1>
<p>Bootstrap is the most popular HTML, CSS...</p>
</div>
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1>Bootstrap Tutorial</h1>
<p>Bootstrap is the most popular HTML, CSS...</p>
</div>
</div>
display-1|2|3|4
: define header for element<h1 class="display-1">Display 1</h1>
font-weight-bold
: bold textfont-weight-bolder
: bolder textfont-italic
: italic textfont-weight-light
: light textfont-weight-lighter
: lighter textfont-weight-normal
: normal text<p class="font-weight-bold">Bold text</p>
text-left
: left aligned texttext-sm|md|lg|xl-left
: left-aligned text on screen sizetext-right
: right aligned texttext-sm|md|lg|xl-right
: right aligned text on screens sizetext-center
: center aligned texttext-sm|md|lg|xl-center
: center aligned text on screens sizetext-justify
: justified text<p class="text-right">Right-aligned text</p>
text-monospace
: monospaced texttext-lowercase
: lowercased texttext-uppercase
: uppercased texttext-capitalize
: capitalized texttext-break
: prevents long text from breaking layouttext-nowrap
: no wrap texttext-reset
: resets color of text/linktext-decoration-none
: removes underline from link<p class="text-uppercase">Uppercased text</p>
list-unstyled
: add to <ul>
/<ol>
to remove default list-style & ml on list items (this class only applies to immediate children list items)list-inline
: place all list items on single line (used together with .list-inline-item on each <li>
elements)<ul class="list-unstyled">
<li>Coffee</li>
<li>Milk</li>
</ul>
<ul class="list-inline">
<li class="list-inline-item">Coffee</li>
<li class="list-inline-item">Tea</li>
</ul>
lead
: makes paragraph stand outsmall
: small text than parentinitialism
: display text inside <abbr>
element in slightly smaller font sizepre-scrollable
: make <pre>
element scrollable<p class="lead">This paragraph stands out</p>
<p>The <abbr title="World Health Organization" class="initialism">WHO</abbr> was founded in 1948</p>
<pre class="pre-scrollable">
Text in pre element is displayed in fixed-width font & it preservea both spaces & line breaks.
</pre>
justify-content
: justify content to start (default)justify-content-start|end|center|between|around
: justifies inside content toalign-content-start|end|center|between|around|stretch
: align content toalign-items-start|end|center|baseline|stretch
: align item tofloat-left|right
: float image to left or rightclearfix
: clear floats<div class="clearfix">
<span class="float-left">Float left</span>
<span class="float-right">Float right</span>
</div>
float-sm|md|lg|xl-left|right
: float depends on screen width<div class="float-sm-right">Float right on small screens or wider</div>
w-%
: set width to %mw-%
: set max-width to %h-%
: set height to %mh-%
: set max-height to %<div class="h-50 w-25 bg-warning">Width 25%, Height 50%</div>
property-size
: set margin/paddingproperty(side)-size
: set specific sides margin/paddingproperty(side)-screen-size
: set margin/padding according to screen widthproperty-auto
: set margin/padding auto<div class="pt-4 bg-warning">Padding 1.5rem</div>
<div class="m-5 pb-5 bg-info">Margin 3rem & Bottom Padding 3rem</div>
<div class="mb-sm-5 bg-warning">Margin Bottom 3rem on sm screens</div>
<div class="px-xl-5 bg-primary">Padding on x 5 on xl screens</div>
Set left & right margin to auto i.e. mx-auto
<div class="mx-auto bg-warning" style="width:150px">Centered</div>
Only for inline elements.
align-baseline
: align to linealign-top
: align above linealign-middle
: align to middle of linealign-bottom
: align to bottom of linealign-text-top
: align text to top of linealign-text-bottom
: align text to bottom of line<span class="align-baseline">baseline</span>
visible
: make element visible (visibility:visible)invisible
: make element invisible (visibility:hidden)<div class="visible">I am visible</div>
fixed-top|bottom
: fixed to top or bottomsticky-top
: sticks to top on scrollFixed nav-bar at top -
<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">...</nav>
d-block
: add to make element block leveld-sm|md|lg|xl-block
: make block level depends on screen widthd-none
: set display property noned-sm|md|lg-none
: make display none depends on srceen widthd-inline
: make element inlined-sm|md|lg|xl-inline
: make element inline on specific screen widthd-inline-block
: make element inline blockd-sm|md|lg|xl-inline-block
: make element inline-block on specific screen size<span class="d-block bg-success">d-block</span>
<span class="d-sm-block bg-success">d-sm-block</span>
d-table
: add to <div>
to make element display as tabled-sm|md|lg|xl-table
: add to <div>
make element display as table depends on screen sized-table-cell
: add to <div>
inside table make element display as table celld-sm|md|lg|xl-table-cell
: add to <div>
to make element display as table cell depends on screen sized-table-row
: add to <div>
inside cell to make element display as table rowd-sm|md|lg|xl-table-row
: add to <div>
to make element display as table row depends on screen size<div class="d-table" style="width:100%">
<div class="d-table-row" style="width:100%">
<div class="d-table-cell">
<h4>Left Cell</h4>
<p>Some text</p>
</div>
<div class="d-table-cell">
<h4>Middle Cell</h4>
<p>Some text</p>
</div>
<div class="d-table-cell">
<h4>Right Cell</h4>
<p>Some text</p>
</div>
</div>
</div>
d-flex
: create flexbox container & transform direct children into flex itemsd-md|sm|lg|xl-flex
: create flexbox container depends on screen sized-inline-flex
: create inline flexbox containerd-sm|md|lg|xl-inline-flex
: create inline flexbox container depends on screen size<div class="d-flex p-3 bg-secondary text-white">
<div class="p-2 bg-info">Flex item 1</div>
<div class="p-2 bg-warning">Flex item 2</div>
<div class="p-2 bg-primary">Flex item 3</div>
</div>
text-primary
: bluetext-secondary
: silver greytext-success
: greentext-info
: cyantext-warning
: yellowtext-danger
: redtext-dark
: dark greytext-light
: light greytext-body
: black (default color)text-white
: whitetext-muted
: greytext-class-opacity
: text-dark-50 (50% opacity text)<p class="text-primary">This text is important</p>
<a href="#" class="text-success">Success link</a>
<p class="text-black-50">Black text with 50% opacity on white background</p>
bg-primary
: bluebg-secondary
: greybg-success
: greenbg-info
: cyanbg-warning
: yellowbg-danger
: redbg-dark
: dark greybg-light
: light grey<p class="bg-primary text-white">This text is important</p>
sr-only
: to hide element on all devices, except screen readers<span class="sr-only">I will be hidden on all screens except for screen readers.</span>
embed-responsive-aspectRatio
: add to parent element of video/iframe (div/span)embed-responsive-item
: add to <video>/<iframe>
Frame will be open is ratio 21:9 on screen -
<div class="embed-responsive embed-responsive-21by9">
<iframe class="embed-responsive-item" src="..."></iframe>
</div>
border
: add default border to elementborder-0
: set border width to 0border-top|bottom|left|right-0
: set specific border to 0<span class="border"></span>
<span class="border border-0"></span>
<span class="border border-top-0"></span>
border-primary
: blueborder-secondary
: greyborder-success
: greenborder-info
: cyanbirder-warning
: yellowborder-danger
: redborder-dark
: dark greyborder-light
: light greyborder-white
: white<span class="border border-primary"></span>
rounded
: rounded borderrounded-sm
: rounded border on sm, lg & xl screensrounded-lg
: rounded border on lg and xl screensrounded-left|right|top|bottom
: border to specific siderounded-circle
: border of 50% radiusrounded-0
: no rounded border<span class="rounded-lg"></span>
shadow
: add default shadow to elementshadow-none
: no shadowshadow-sm|lg
: add shadow on sm & lg shadow<div class="shadow-none p-4 mb-4 bg-light">No shadow</div>
<div class="shadow-sm p-4 mb-4 bg-white">Small shadow</div>
table
: add to <table>
for basic table style<table class="table">
<thead>
<tr>
<th>Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</tbody>
</table>
table-striped
: add zebra-stripes to rowstable-bordered
: add borders on all sides of table and cellstable-hover
: add hover effect (grey background color) on table rowstable-dark
: add dark background to tabletable-borderless
: removes borders from tabletable-sm
: make table smaller by cutting cell padding in halfAdd in <table>
.
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th>header</th>
</tr>
</thead>
<tbody>
<tr>
<td>text 1</td>
</tr>
<tr>
<td>text 2</td>
</tr>
</tbody>
</table>
table-responsive
: add scrollbar to table when neededtable-responsive-sm|md|lg|xl
: add scrollbar to table when needed depends on screen widthAdd in parent <div>
element of table.
<div class="table-responsive">
<table class="table table-bordered"> ... </table>
</div>
thead-dark
: add dark background to table headerthead-light
: add grey background to table headerAdd in table header <thead>
.
<table class="table table-striped table-sm">
<thead class="thead-dark">
<tr>
<th>header</th>
</tr>
</thead>
<tbody>
<tr>
<td>text 1</td>
</tr>
<tr>
<td>text 2</td>
</tr>
</tbody>
</table>
table-primary
: bluetable-success
: greentable-info
: cyantable-warning
: yellowtable-danger
: redtable-active
: greytable-secondary
: greytable-light
: light greytable-dark
: dark greyFor row/col.
<table class="table table-striped">
<thead>
<tr class="table-primary">
<th>header</th>
</tr>
</thead>
<tbody>
<tr class="table-light text-dark">
<td>text 1</td>
</tr>
</tbody>
</table>
rounded
: add rounded corners to imagerounded-circle
: shape image to circleimg-thumbnail
: shape image to thumbnail (bordered)float-left
: float image to leftfloat-right
: float image to rightimg-fluid
: image scale to parent element<img src="cinqueterre.jpg" class="rounded" alt="Cinque Terre">
<img src="paris.jpg" class="float-left">
<img src="paris.jpg" class="mx-auto d-block">
alert
: default alert<div class="alert">
<strong>Alert!</strong> This is alert-box
</div>
alert-success
alert-info
alert-warning
alert-danger
alert-primary
alert-secondary
alert-light
alert-dark
<div class="alert alert-success">
<strong>Success!</strong> Indicates a successful or positive action.
</div>
alert-link
: add to links <a>
inside alert box to create matching colored links<div class="alert alert-success">
<strong>Success!</strong> You should <a href="#" class="alert-link">read this message</a>.
</div>
.fade
and .show
class to alert box<div class="alert alert-success alert-dismissible fade show">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Success!</strong> This alert box could indicate a successful or positive action.
</div>
alert-dismissible
: add to create dismussible alert box<div class="alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Success!</strong> Indicates a successful or positive action.
</div>
btn
: add to <button>/<input>/<a>
for basic button style<button type="button" class="btn">Basic</button>
btn-block
: make button block-level that spans full widthactive
: active buttondisable
: disabled button<button type="button" class="btn btn-primary btn-block">Full-Width Button</button>
<button type="button" class="btn btn-primary active">Active Primary</button>
<a href="#" class="btn btn-primary disabled">Disabled Link</a>
btn-primary
: bluebtn-secondary
: greybtn-success
: greenbtn-info
: cyanbtn-warning
: yellowbtn-danger
: redbtn-light
: light greybtn-dark
: dark greybtn-link
: no color<button type="button" class="btn btn-warning">Warning</button>
btn-outline-primary
: bluebtn-outline-secondary
: greybtn-outline-success
: greenbtn-outline-info
: cyanbtn-outline-warning
: yellowbtn-outline-danger
: redbtn-outline-light
: light greybtn-outline-dark
: dark grey<button type="button" class="btn btn-outline-primary">Primary</button>
spinner-border
: spinner buttonspinner-border-sm
: small size spinner button<button class="btn btn-primary">
<span class="spinner-border spinner-border-sm"></span>
</button>
btn-sm
: small size buttonbtn-lg
: large size button<button type="button" class="btn btn-primary btn-lg">Large</button>
btn-group
: add to parent <div>
of <button>
for horizontal group buttonsbtn-group-vertical
: add to parent <div>
of <button>
for vertical group buttons<div class="btn-group">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
</div>
<div class="btn-group-vertical">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
</div>
btn-group-sm
: small buttonbtn-group-lg
: large button<div class="btn-group btn-group-lg">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Sony</button>
</div>
<div class="btn-group">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Sony
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Tablet</a>
<a class="dropdown-item" href="#">Smartphone</a>
</div>
</div>
</div>
dropdown-toggle-split
: add to button for split<div class="btn-group">
<button type="button" class="btn btn-primary">Sony</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
<span class="caret"></span>
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Tablet</a>
<a class="dropdown-item" href="#">Smartphone</a>
</div>
</div>
badge
: add badge to <span>
<span class="badge">Badge</span>
badge-pill
: to make badges more round<span class="badge badge-pill badge-primary">Primary</span>
badge-primary
: bluebadge-secondary
: greybadge-success
: greenbadge-info
: cyanbadge-warning
: yellowbadge-danger
: redbadge-light
: light greybadge-dark
: dark grey<span class="badge badge-primary">Primary</span>
progress
: add progress to parent <div>
progress-bar
: add progress-bar inside of parent progress for progress status<div class="progress">
<div class="progress-bar" style="width:70%"> 70% </div>
</div>
progress-bar-striped
: add stripes to progress barprogress-bar-animated
: for animating progress bar<div class="progress">
<div class="progress-bar progress-bar-striped" style="width:40%"></div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:40%"></div>
</div>
Use contextual color classes for bg & text color.
<div class="progress">
<div class="progress-bar bg-success" style="width:40%">
Free Space
</div>
<div class="progress-bar bg-warning" style="width:10%">
Warning
</div>
<div class="progress-bar bg-danger" style="width:20%">
Danger
</div>
</div>
spinner-border
: add to <div>/<span>
for spinner of spinning borderUse contextual color classes for color.
<div class="spinner-border text-primary"></div>
spinner-grow
: add to <div>/<span>
for growing spinner<div class="spinner-grow text-muted"></div>
spinner-border-sm|lg
: spinner sizespinner-grow-sm|lg
: spinner size<div class="spinner-border spinner-border-sm"></div>
<div class="spinner-grow spinner-grow-sm"></div>
pagination
: add class to <ul>
page-item
: add to each <li>
inside <ul>
page-link
: add to each link <a>
inside of <li>
active
: add to <li>
for highlight current pagedisabled
: add to <li>
for disable page click<ul class="pagination">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item active"><a class="page-link" href="#">2</a></li>
<li class="page-item disabled"><a class="page-link" href="#">3</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
pagination-sm|lg
: small & large pagination<ul class="pagination pagination-lg">
<li class="page-item"><a class="page-link" href="#">Previous</a></li>
<li class="page-item"><a class="page-link" href="#">1</a></li>
<li class="page-item"><a class="page-link" href="#">2</a></li>
<li class="page-item"><a class="page-link" href="#">Next</a></li>
</ul>
justify-content-center
: center alignedjustify-content-end
: right aligned<ul class="pagination justify-content-end" style="margin:20px 0">
<li class="page-item">...</li>
</ul>
Indicates current page's location within navigational hierarchy.
breadcrumb
: add to <ul>
breadcrumb-item
: add to each <li>
<ul class="breadcrumb">
<li class="breadcrumb-item"><a href="#">Photos</a></li>
<li class="breadcrumb-item"><a href="#">Summer 2017</a></li>
<li class="breadcrumb-item"><a href="#">Italy</a></li>
<li class="breadcrumb-item active">Rome</li>
</ul>
list-group
: add to <ul>
list-group-item
: add to each <li>
active
: add to <li>/<a>
for highlight current pagedisabled
: add to <li>/<a>
for disable list<ul class="list-group">
<li class="list-group-item">First item</li>
<li class="list-group-item active">Second item</li>
<li class="list-group-item">
Inbox
<span class="badge badge-primary badge-pill">12</span>
</li>
</ul>
list-group
: add to <div>
list-group-items
: add to each <a>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action">First item</a>
<a href="#" class="list-group-item list-group-item-action">Second item</a>
<a href="#" class="list-group-item disabled">Disabled item</a>
</div>
list-group-horizontal
: groups list horizontally<ul class="list-group list-group-horizontal">
<li class="list-group-item">First item</li>
<li class="list-group-item">Second item</li>
</ul>
list-group-flush
: add to <ul>
to remove border & rounded cornerslist-group-item-action
: add to <li>
to create grey bg on hover<ul class="list-group list-group-flush">
<li class="list-group-item">First item</li>
<li class="list-group-item list-group-item-action">Second item</li>
</ul>
list-group-item-action
: whitelist-group-item-success
: greenlist-group-item-secondary
: greylist-group-item-info
: cyanlist-group-item-warning
: yellowlist-group-item-danger
: redlist-group-item-primary
: bluelist-group-item-dark
: dark greylist-group-item-light
: light grey<ul class="list-group">
<li class="list-group-item list-group-item-success">Success item</li>
<li class="list-group-item list-group-item-secondary">Secondary item</li>
</ul>
<div class="list-group">
<a href="#" class="list-group-item list-group-item-action list-group-item-dark">Action item</a>
<a href="#" class="list-group-item list-group-item-action list-group-item-success">Success item</a>
</div>
card
: add to parent <div>
for basic cardcard-header
: add inside card for card headercard-body
: add inside card for card bodycard-footer
: add inside card for card footercard-title
: add inside body for titlecard-text
: add add inside body for textcard-link
: add add inside body for card linkUse contextual colors for bg & text colors.
<div class="card">
<div class="card-body">
<h4 class="card-title">Card title</h4>
<p class="card-text">Some example text. Some example text.</p>
<a href="#" class="card-link">Card link</a>
<a href="#" class="card-link">Another link</a>
</div>
</div>
card-img-top
: add inside card for add image to topcard-img-bottom
: add inside card for add image to bottom<div class="card" style="width:400px">
<img class="card-img-top" src="img_avatar1.png" alt="Card image">
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p class="card-text">Some example text</p>
<a href="#" class="btn btn-primary">See Profile</a>
</div>
</div>
stretched-link
: add inside make whole card clickable & hoverable<div class="card" style="width:400px">
<img class="card-img-top" src="img_avatar1.png" alt="Card image" style="width:100%">
<div class="card-body">
<h4 class="card-title">John Doe</h4>
<p class="card-text">Some example text some example text. John Doe is an architect and engineer</p>
<a href="#" class="btn btn-primary stretched-link">See Profile</a>
</div>
</div>
card-img-overlay
: add inside card for text on top of image<div class="card" style="width:500px">
<img class="card-img-top" src="img_avatar1.png" alt="Card image">
<div class="card-img-overlay">
<h4 class="card-title">John Doe</h4>
<p class="card-text">Some example text.</p>
<a href="#" class="btn btn-primary">See Profile</a>
</div>
</div>
card-columns
: add to parent <div>
of card to create grid of cards (like pinterest)Note : The layout will automatically adjust as you insert more cards. Cards are displayed vertically on small screens (<576px).
<div class="card-columns">
<div class="card bg-primary">
<div class="card-body text-center">
<p class="card-text">Some text inside the first card</p>
</div>
</div>
<div class="card bg-warning">
<div class="card-body text-center">
<p class="card-text">Some text inside the second card</p>
</div>
</div>
<div class="card bg-info">
<div class="card-body text-center">
<p class="card-text">Some text inside the sixth card</p>
</div>
</div>
</div>
card-deck
: add to parent <div>
of card to create grid of cards are of equal height & widthNote : The layout will automatically adjust as you insert more cards. Cards are displayed vertically on small screens (<576px).
<div class="card-deck">
<div class="card bg-primary">
<div class="card-body text-center">
<p class="card-text">Some text inside the first card</p>
</div>
</div>
<div class="card bg-warning">
<div class="card-body text-center">
<p class="card-text">Some text inside the second card</p>
</div>
</div>
<div class="card bg-success">
<div class="card-body text-center">
<p class="card-text">Some text inside the third card</p>
</div>
</div>
</div>
card-group
: add to parent <div>
of card to create group of cards (same as card column & deck but it removes left & right margin)Note : The layout will automatically adjust as you insert more cards. Cards are displayed vertically on small screens (<576px) with a top and bottom margin.
<div class="card-group">
<div class="card bg-primary">
<div class="card-body text-center">
<p class="card-text">Some text inside the first card</p>
</div>
</div>
<div class="card bg-warning">
<div class="card-body text-center">
<p class="card-text">Some text inside the second card</p>
</div>
</div>
<div class="card bg-success">
<div class="card-body text-center">
<p class="card-text">Some text inside the third card</p>
</div>
</div>
</div>
dropdown
: add to <div>
element for dropdown menudropdown-menu
: add to <div>
inside dropdown for menu for dropdowndropdown-item
: add to each <div>
for dropdown itemsdropdown-toggle
: add to <button>/<a>
for dropdown toggledata-toggle="dropdown"
: add to <button>/<a>
to made toggle as dropdown<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
</div>
</div>
active
: add to <a>
of each menu for highlight active classdisabled
: add to <a>
of each menu for disable item<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Normal</a>
<a class="dropdown-item active" href="#">Active</a>
<a class="dropdown-item disabled" href="#">Disabled</a>
</div>
</div>
dropdown-divider
: add to <div>
for dividing dropdown list & link with thin horiz border<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Another link</a>
</div>
</div>
dropdown-header
: add inside of dropdown menu for header<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<h5 class="dropdown-header">Dropdown header</h5>
<a class="dropdown-item" href="#">Link 1</a>
<h5 class="dropdown-header">Dropdown header</h5>
<a class="dropdown-item" href="#">Another link</a>
</div>
</div>
dropleft
: add to dropdown class for left dropdown menudropright
: add to dropdown class for right dropdown menudropup
: add instead of dropdown for dropup menudropdown-menu-right
: add to dropdown class for right-align dropdown menu<div class="dropdown dropright">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropright button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
</div>
</div>
<div class="dropup">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropup button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
</div>
</div>
dropdown-item-text
: add text with dropdown link<div class="dropdown">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item-text" href="#">Text Link</a>
<span class="dropdown-item-text">Just Text</span>
</div>
</div>
<div class="btn-group">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Sony
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Tablet</a>
<a class="dropdown-item" href="#">Smartphone</a>
</div>
</div>
</div>
dropdown-toggle-split
: add to button to split button & dropdown toggle<div class="btn-group">
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-primary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown">
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
</div>
</div>
btn-group-vertical
: add to parent <div>
for vertical button group<div class="btn-group-vertical">
<button type="button" class="btn btn-primary">Apple</button>
<button type="button" class="btn btn-primary">Samsung</button>
<div class="btn-group">
<button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
Sony
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Tablet</a>
<a class="dropdown-item" href="#">Smartphone</a>
</div>
</div>
</div>
collapse
: add to <div>
to make collapsible elementdata-toggle="collapse"
: to control (show/hide) collapsible content add attribute to <button>/<a>
data-target="#id"
: add attribute to connect button with collapsible content (<div id="demo">
)hide
(default) : hide contentshow
: show content<button data-toggle="collapse" data-target="#demo">Collapsible</button>
<div id="demo" class="collapse">
Text Here
</div>
Note : for <a>
href attribute can be used instead of data-target attribute -
<a href="#demo" data-toggle="collapse">Collapsible</a>
<div id="demo" class="collapse">
Text Here
</div>
<div id="accordion">
<div class="card">
<div class="card-header">
<a class="card-link" data-toggle="collapse" href="#collapseOne">
Collapsible Group Item #1
</a>
</div>
<div id="collapseOne" class="collapse show" data-parent="#accordion">
<div class="card-body">
Lorem ipsum..
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<a class="collapsed card-link" data-toggle="collapse" href="#collapseTwo">
Collapsible Group Item #2
</a>
</div>
<div id="collapseTwo" class="collapse" data-parent="#accordion">
<div class="card-body">
Lorem ipsum..
</div>
</div>
</div>
</div>
Slideshow sliding through elements.
carousel
: add to <div>
for creating carousel of imageslide
: add with corousel for make slide of imagescarousel-indicators
: add to <ul>
inside <div>
for indicators for carousel (little dots at bottom of each slide)carousel-inner
: add to <div>
to define slides to carouselcarousel-item
: add to <div>
for content of each slidecarousel-control-prev
: add to <a>
for left (previous) button to carouselcarousel-control-next
: add to <a>
for right (next) button to carouselcarousel-control-prev-icon
: used together with .carousel-control-prev to create "previous" buttoncarousel-control-next-icon
: used together with .carousel-control-next to create "next" buttonslide
: add to CSS transition & animation effect when sliding from one item to nextdata-ride="carousel"
in .carousel
class.data-slide-to="0"
no to each <li>
item.<div id="demo" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
<li data-target="#demo" data-slide-to="1"></li>
<li data-target="#demo" data-slide-to="2"></li>
</ul>
<!-- The slideshow -->
<div class="carousel-inner">
<div class="carousel-item active">
<img src="la.jpg" alt="Los Angeles">
</div>
<div class="carousel-item">
<img src="chicago.jpg" alt="Chicago">
</div>
<div class="carousel-item">
<img src="ny.jpg" alt="New York">
</div>
</div>
<!-- Left and right controls -->
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
carousel-caption
: add within each <div class="carousel-item">
to create caption for each slide<div id="demo" class="carousel slide" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>
</ul>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="la.jpg" alt="Los Angeles" width="1100" height="500">
<div class="carousel-caption">
<h3>Los Angeles</h3>
<p>We had such a great time in LA!</p>
</div>
</div>
</div>
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
modal
: add to <div>
to create modalmodal-dialog
: add to <div>
inside .modal for modal elementsmodal-content
: add to <div>
inside .modal-dialog for modal contentmodal-header
: add to <div>
inside .modal-content for modal headermodal-title
: add to <div>/<h>
inside .modal-header for header titlemodal-body
: add to <div>
inside .modal-content for modal bodymodal-footer
: add to <div>
inside .modal-content for modal footer<button>
& add data-toggle="modal" & target="#id" to <button>
.<button>
inside header or footer & add data-dismiss="modal" to <button>
.<!-- Button to Open the Modal -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
Open modal
</button>
<!-- The Modal -->
<div class="modal" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Modal Heading</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
Modal body..
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
fade
: add with .modal
class for open/close fading animation<div class="modal fade"> ... </div>
modal-sm|lg|xl
(default md) : add with .modal-dialog
class for sizing modal<div class="modal-dialog modal-sm"> ... </div>
modal-dialog-centered
: add with .modal-dialog
for center modal vertically & horizontally within page<div class="modal-dialog modal-dialog-centered"> ... </div>
modal-dialog-scrollable
: add with .modal-dialog
to only scroll inside modal body instead of page itself<div class="modal-dialog modal-dialog-scrollable"> ... </div>
data-toggle="tooltip"
: add attribute to element to create tooltiptitle="Hover Text"
: add attribute to element for hover textdata-placement="top|bottom|left|right"
: add attribute to element for placement of tooltip<a href="#" data-toggle="tooltip" title="Hooray!">Hover over me</a>
<a href="#" data-toggle="tooltip" data-placement="top" title="Hooray!">Hover</a>
Note : Tooltips must be initialised with jQuery; select the specified element & call the tooltip() method. The following code will enable all tooltips in the document -
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
data-toggle="popover"
: add attribute to element to create popovertitle="text"
: add attribute to element for popover header textdata-content="content text"
: add attribute to element for popover body textdata-placement="top|bottom|left|right"
: add attribute to element for placement of popoverdata-trigger="focus"
: add attribute to element to close popover when clicking outside elementdata-trigger="hover"
: add attribute to element for popover to be display when mouse-over element<a href="#" data-toggle="popover" title="Popover Header" data-content="Some content inside popover">Toggle popover</a>
<a href="#" data-toggle="popover" title="Header" data-placement="top" data-content="Content">Click</a>
<a href="#" title="Dismissible popover" data-toggle="popover" data-trigger="focus" data-content="Click anywhere in document to close this popover">Click</a>
<a href="#" title="Dismissible Popover" data-toggle="popover" data-trigger="hover" data-content="Click anywhere in document to close this popover">Click</a>
Note : Popovers must be initialised with jQuery, select the specified element and call the popover() method. The following code will enable all popovers in this document -
<script>
$(document).ready(function(){
$('[data-toggle="popover"]').popover();
});
</script>
toast
: add to element (<div>)
to create toasttoast-header
: add to element (<div>)
inside .toast
for toast headertoast-body
: add to element (<div>)
inside .toast
for toast bodydata-autohide="false"
: add attribute with .toast
for toasts to show by default (default hidden)data-dismiss="toast"
: add attribute to <button>
to close toast<div class="toast">
<div class="toast-header">
Toast Header
</div>
<div class="toast-body">
Some text inside the toast body
</div>
</div>
<div class="toast" data-autohide="false">
<div class="toast-header">
<strong class="mr-auto text-primary">Toast Header</strong>
<small class="text-muted">5 mins ago</small>
<button type="button" class="ml-2 mb-1 close" data-dismiss="toast">×</button>
</div>
<div class="toast-body">
Some text inside the toast body
</div>
</div>
Note : Toasts must be initialised with jQuery; select the specified element & call the toast() method. The following code will show all "toasts" in the document -
<script>
$(document).ready(function(){
$('.toast').toast('show');
});
</script>
data-spy="scroll"
: add attribute to scrollable element Ex. <body>
data-target="#id|.class"
: add attribute to target navigation bar and set class/iddata-offset="value"
: set number of pixels to offset from top when calculating position of scroll (optional)Note : Scrollable element must match id/class of links inside navbar's list items (<div id="section1">
matches <a href="#section1">
).
<body data-spy="scroll" data-target=".navbar" data-offset="50">
<nav class="navbar navbar-expand-sm bg-dark navbar-dark fixed-top">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#section1">Section 1</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbardrop" data-toggle="dropdown">Section 2</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#section21">Link 1</a>
<a class="dropdown-item" href="#section22">Link 2</a>
</div>
</li>
</ul>
</nav>
<div id="section1" class="container-fluid bg-success" style="padding-top:70px;padding-bottom:70px">
<h1>Section 1</h1>
<p>Try to scroll this section and look at navigation bar while scrolling!</p>
<p>Try to scroll this section and look at navigation bar while scrolling!</p>
</div>
<div id="section21" class="container-fluid bg-danger" style="padding-top:70px;padding-bottom:70px">
<h1>Section 2 Submenu 1</h1>
<p>Try to scroll this section and look at navigation bar while scrolling!</p>
<p>Try to scroll this section and look at navigation bar while scrolling!</p>
</div>
<div id="section22" class="container-fluid bg-info" style="padding-top:70px;padding-bottom:70px">
<h1>Section 2 Submenu 2</h1>
<p>Try to scroll this section and look at navigation bar while scrolling!</p>
<p>Try to scroll this section and look at navigation bar while scrolling!</p>
</div>
</body>
<body data-spy="scroll" data-target="#myScrollspy" data-offset="1">
<div class="container-fluid">
<div class="row">
<nav class="col-sm-3 col-4" id="myScrollspy">
<ul class="nav nav-pills flex-column">
<li class="nav-item">
<a class="nav-link active" href="#section1">Section 1</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">Section 2</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#section21">Link 1</a>
<a class="dropdown-item" href="#section22">Link 2</a>
</div>
</li>
</ul>
</nav>
<div class="col-sm-9 col-8">
<div id="section1" class="bg-success">
<h1>Section 1</h1>
<p>Try to scroll this section and look at navigation list while scrolling!</p>
</div>
<div id="section21" class="bg-danger">
<h1>Section 2-1</h1>
<p>Try to scroll this section and look at navigation list while scrolling!</p>
</div>
<div id="section22" class="bg-info">
<h1>Section 2-2</h1>
<p>Try to scroll this section and look at navigation list while scrolling!</p>
</div>
</div>
</div>
</div>
</body>
media
: add to <div>
element for creating media & must be add inside containermedia-body
: add to <div>
inside .media
for adding content<div class="media border p-3">
<img src="img_avatar3.png" alt="John Doe" class="mr-3 mt-3 rounded-circle" style="width:60px;">
<div class="media-body">
<h4>John Doe <small><i>Posted on February 19, 2016</i></small></h4>
<p>Lorem ipsum...</p>
</div>
</div>
<div class="media border p-3">
<img src="img_avatar3.png" alt="John Doe" class="mr-3 mt-3 rounded-circle" style="width:60px;">
<div class="media-body">
<h4>John Doe <small><i>Posted on February 19, 2016</i></small></h4>
<p>Lorem ipsum...</p>
<div class="media p-3">
<img src="img_avatar2.png" alt="Jane Doe" class="mr-3 mt-3 rounded-circle" style="width:45px;">
<div class="media-body">
<h4>Jane Doe <small><i>Posted on February 20 2016</i></small></h4>
<p>Lorem ipsum...</p>
</div>
</div>
</div>
</div>
<div class="media border p-3">
<div class="media-body">
<h4>John Doe <small><i>Posted on February 19, 2016</i></small></h4>
<p>Lorem ipsum...</p>
</div>
<img src="img_avatar3.png" alt="John Doe" class="ml-3 mt-3 rounded-circle" style="width:60px;">
</div>
<div class="media">
<img src="img_avatar1.png" class="align-self-start mr-3" style="width:60px">
<div class="media-body">
<h4>Media Top</h4>
<p>Lorem ipsum...</p>
</div>
</div>
<div class="media">
<img src="img_avatar1.png" class="align-self-center mr-3" style="width:60px">
<div class="media-body">
<h4>Media Middle</h4>
<p>Lorem ipsum...</p>
</div>
</div>
<div class="media">
<img src="img_avatar1.png" class="align-self-end mr-3" style="width:60px">
<div class="media-body">
<h4>Media Bottom</h4>
<p>Lorem ipsum...</p>
</div>
</div>
form-group
: add wrapper <div>
with this class to each form's element for full width stacked form<form action="/action_page.php">
<div class="form-group">
<label for="email">Email address:</label>
<input type="email" class="form-control" placeholder="Enter email" id="email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" placeholder="Enter password" id="pwd">
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox"> Remember me
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
form-inline
: add to <form>
for inline forms<form class="form-inline" action="/action_page.php"> ... </form>
row|form-row
: add to wrapper <div>
to create row form elementcol
: to add <div>
inside .row to create col for each element<form>
<div class="form-row">
<div class="col">
<input type="text" class="form-control" id="email" placeholder="Enter email" name="email">
</div>
<div class="col">
<input type="password" class="form-control" placeholder="Enter password" name="pswd">
</div>
</div>
</form>
was-validated
: add to <form>
for validate before submisionneeds-validation
: add to <form>
for validate after submisionvalid-feedback
: add to seperate <div>
with message for feedback if form is validinvalid-feedback
: add to seperate <div>
with message for feedback if form is invalid<form action="/action_page.php" class="was-validated">
<div class="form-group">
<label for="uname">Username:</label>
<input type="text" class="form-control" id="uname" placeholder="Enter username" name="uname" required>
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Please fill out this field.</div>
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pswd" required>
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Please fill out this field.</div>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="remember" required> I agree on blabla.
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Check this checkbox to continue.</div>
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<form action="/action_page.php" class="needs-validation" novalidate>
<div class="form-group">
<label for="uname">Username:</label>
<input type="text" class="form-control" id="uname" placeholder="Enter username" name="uname" required>
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Please fill out this field.</div>
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pswd" required>
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Please fill out this field.</div>
</div>
<div class="form-group form-check">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" name="remember" required> I agree on blabla.
<div class="valid-feedback">Valid.</div>
<div class="invalid-feedback">Check this checkbox to continue.</div>
</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
<script>
// Disable form submissions if there are invalid fields -
(function() {
'use strict';
window.addEventListener('load', function() {
// Get the forms we want to add validation styles to -
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission -
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
}, false);
})();
</script>
form-control
: add to <input>
to style inputs with full-width & proper paddingform-control-sm|lg
: add to <input>
for input on specific screen size<input type="text" class="form-control form-control-sm">
<input type="text" class="form-control form-control">
<input type="text" class="form-control form-control-lg">
form-control-plaintext
: add to <input>
for plain text form without border<input type="text" class="form-control-plaintext">
form-control-file
: for input type file<input type="file" class="form-control-file border">
form-control-range
: for input type range<input type="range" class="form-control-range">
form-control
: add to <input>
<div class="form-group">
<label for="usr">Name:</label>
<input type="text" class="form-control" id="usr">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd">
</div>
form-control
: add to <textarea>
<div class="form-group">
<label for="comment">Comment:</label>
<textarea class="form-control" rows="5" id="comment"></textarea>
</div>
form-check
: add to wrapper <div>
to create checkboxform-check-label
: add to <label>
to set label of checkboxform-check-input
: add to <input>
type checkbox for checkbox selectiondisabled
: add to <input>
to disable check item<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" value="">Option 1
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" value="">Option 2
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" value="" disabled>Option 3
</label>
</div>
form-check-inline
: add to wrapper <div>
to create inline checkboxes<div class="form-check-inline">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" value="">Option 1
</label>
</div>
<div class="form-check-inline">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" value="">Option 2
</label>
</div>
<div class="form-check-inline">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" value="" disabled>Option 3
</label>
</div>
form-check
: add to wrapper <div>
to create radio buttonform-check-label
: add to <label>
to set label of radio buttonform-check-input
: add to <input>
type radiodisabled
: add to <input>
to disable check item<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optradio">Option 1
</label>
</div>
<div class="form-check">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optradio">Option 2
</label>
</div>
<div class="form-check disabled">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optradio" disabled>Option 3
</label>
</div>
form-check-inline
: add to wrapper <div>
to create inline radio buttons<div class="form-check-inline">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optradio">Option 1
</label>
</div>
<div class="form-check-inline">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optradio">Option 2
</label>
</div>
<div class="form-check-inline disabled">
<label class="form-check-label">
<input type="radio" class="form-check-input" name="optradio" disabled>Option 3
</label>
</div>
form-check
: add to wrapper <div>
to create select listform-control
: add to <select>
for styling options<div class="form-group">
<label for="sel1">Select list:</label>
<select class="form-control" id="sel1">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
</div>
input-group
: add to wrapper <div>
container to enhance input by adding icon/text/button in front/behind input field as help textinput-group-prepend
: add to <div>
for help text front of inputinput-group-append
: add to <div>
for help text behind inputinput-group-text
: add to <span>
for specified help text<form>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">@</span>
</div>
<input type="text" class="form-control" placeholder="Username">
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Your Email">
<div class="input-group-append">
<span class="input-group-text">@example.com</span>
</div>
</div>
</form>
input-group-sm|lg
: add with .input-group
for sizing input groups (default md)<form>
<div class="input-group mb-3 input-group-sm">
<div class="input-group-prepend">
<span class="input-group-text">Small</span>
</div>
<input type="text" class="form-control">
</div>
</form>
<form>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">Person</span>
</div>
<input type="text" class="form-control" placeholder="First Name">
<input type="text" class="form-control" placeholder="Last Name">
</div>
</form>
<form>
<div class="input-group mb-3">
<div class="input-group-prepend">
<span class="input-group-text">One</span>
<span class="input-group-text">Two</span>
<span class="input-group-text">Three</span>
</div>
<input type="text" class="form-control">
</div>
</form>
<div class="input-group mb-3">
<div class="input-group-prepend">
<div class="input-group-text">
<input type="checkbox">
</div>
</div>
<input type="text" class="form-control" placeholder="Some text">
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<div class="input-group-text">
<input type="radio">
</div>
</div>
<input type="text" class="form-control" placeholder="Some text">
</div>
<div class="input-group mb-3">
<div class="input-group-prepend">
<button class="btn btn-outline-primary" type="button">Basic Button</button>
</div>
<input type="text" class="form-control" placeholder="Some text">
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Search">
<div class="input-group-append">
<button class="btn btn-success" type="submit">Go</button>
</div>
</div>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Something clever..">
<div class="input-group-append">
<button class="btn btn-primary" type="button">OK</button>
<button class="btn btn-danger" type="button">Cancel</button>
</div>
</div>
<div class="input-group mt-3 mb-3">
<div class="input-group-prepend">
<button type="button" class="btn btn-outline-secondary dropdown-toggle" data-toggle="dropdown">
Dropdown button
</button>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Link 1</a>
<a class="dropdown-item" href="#">Link 2</a>
<a class="dropdown-item" href="#">Link 3</a>
</div>
</div>
<input type="text" class="form-control" placeholder="Username">
</div>
<form>
<label for="demo">Write your email here:</label>
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="Email" id="demo" name="email">
<div class="input-group-append">
<span class="input-group-text">@example.com</span>
</div>
</div>
</form>
custom-control
: add to wrapper <div>
around <input>
to create custom formscustom-control-inline
: add with .custom-control
to create inline custom form elementcustom-control-label
: add to <label>
inside .custom-control
for label text<form>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" id="customRadio" name="example" value="customEx">
<label class="custom-control-label" for="customRadio">Custom radio 1</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" class="custom-control-input" id="customRadio2" name="example" value="customEx">
<label class="custom-control-label" for="customRadio2">Custom radio 2</label>
</div>
</form>
custom-control-input
: add to <input>
custom-checkbox
: add with .custom-control
for custom checkboxes<form>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck" name="example1">
<label class="custom-control-label" for="customCheck">Check this custom checkbox</label>
</div>
</form>
custom-control-input
: add to <input>
custom-switch
: add with .custom-control
for custom switch<form>
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="switch1">
<label class="custom-control-label" for="switch1">Toggle me</label>
</div>
</form>
custom-control-input
: add to <input>
custom-radio
: add with .custom-control
for custom radio buttons<form>
<div class="custom-control custom-radio">
<input type="radio" class="custom-control-input" id="customRadio" name="example1" value="customEx">
<label class="custom-control-label" for="customRadio">Custom radio</label>
</div>
</form>
custom-select
: add to <select>
element for custom select menucustom-select-sm|lg
: add to <select>
element for sizing custom select menu (default md)<form>
<select name="cars" class="custom-select">
<option selected>Custom Select Menu</option>
<option value="volvo">Volvo</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
<form>
<select name="cars" class="custom-select-sm">
<option selected>Small Custom Select Menu</option>
<option value="volvo">Volvo</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
</form>
custom-range
: add to <input>
type range for custom range<form>
<label for="customRange">Custom range</label>
<input type="range" class="custom-range" id="customRange" name="points1">
</form>
custom-file
: add to wrapper <div>
element for custom file uploadcustom-file-input
: add to <input>
type file for custom file upload<form>
<div class="custom-file">
<input type="file" class="custom-file-input" id="customFile">
<label class="custom-file-label" for="customFile">Choose file</label>
</div>
</form>
<script>
// Add the following code if you want the name of the file appear on select -
$(".custom-file-input").on("change", function() {
var fileName = $(this).val().split("\\").pop();
$(this).siblings(".custom-file-label").addClass("selected").html(fileName);
});
</script>
d-flex
: add it to <div>
to create flexbox container & transforms direct children into flex itemsd-md|sm|lg|xl-flex
: add it to <div>
to create flexbox container on specific screen sizeNote : max columns are 12.
<div class="d-flex p-3 bg-secondary text-white">
<div class="p-2 bg-info">Flex item 1</div>
<div class="p-2 bg-warning">Flex item 2</div>
<div class="p-2 bg-primary">Flex item 3</div>
</div>
d-inline-flex
: add it to <div>
to create inline flexbox containerd-sm|md|lg|xl-inline-flex
: add it to <div>
to create inline flexbox container on specific screen size<div class="d-inline-flex p-3 bg-secondary text-white">
<div class="p-2 bg-info">Flex item 1</div>
<div class="p-2 bg-warning">Flex item 2</div>
<div class="p-2 bg-primary">Flex item 3</div>
</div>
flex-row
: add with .d-flex
to display flex items horizontally (side by side)flex-row-reverse
: add with .d-flex
to right-align horizontal direction<div class="d-flex flex-row bg-secondary">
<div class="p-2 bg-info">Flex item 1</div>
<div class="p-2 bg-warning">Flex item 2</div>
<div class="p-2 bg-primary">Flex item 3</div>
</div>
flex-column
: add with .d-flex
to display flex items vertically (on top of each other)flex-column-reverse
: add with .d-flex
to reverse vertical direction<div class="d-flex flex-column">
<div class="p-2 bg-info">Flex item 1</div>
<div class="p-2 bg-warning">Flex item 2</div>
<div class="p-2 bg-primary">Flex item 3</div>
</div>
justify-content-start|end|center|between|around
: add with .d-flex
to justify inside content to following<div class="d-flex justify-content-start">...</div>
<div class="d-flex justify-content-center">...</div>
<div class="d-flex justify-content-end">...</div>
flex-fill
: add to each flex item to force them into equal widths<div class="d-flex">
<div class="p-2 bg-info flex-fill">Flex item 1</div>
<div class="p-2 bg-warning flex-fill">Flex item 2</div>
<div class="p-2 bg-primary flex-fill">Flex item 3</div>
</div>
flex-grow-1
: add to flex item to take up rest of spaceflex-shrink-1
: add to flex item to make it shrink if necessary<div class="d-flex">
<div class="p-2 bg-info">Flex item 1</div>
<div class="p-2 bg-primary flex-grow-1">Flex item 2</div>
</div>
order
: add to flex items to change visual order of specific flex itemNote : Valid classes are from 0-12. The lowest number has the highest priority, i.e., order-1 is shown before order-2.
<div class="d-flex bg-secondary">
<div class="p-2 bg-info order-3">Flex item 1</div>
<div class="p-2 bg-warning order-2">Flex item 2</div>
<div class="p-2 bg-primary order-1">Flex item 3</div>
</div>
Controls how flex items are wrapped in flex containers.
flex-nowrap
: add with d-flex
to no wrapping to flex container (default)flex-wrap
: add with d-flex
to wrap flex containerflex-wrap-reverse
: add with d-flex
to reverse wrap flex container<div class="d-flex flex-wrap">..</div>
<div class="d-flex flex-wrap-reverse">..</div>
<div class="d-flex flex-nowrap">..</div>
Add auto margins to flex items with .mr-auto
, push items to right -
<div class="d-flex bg-secondary">
<div class="p-2 mr-auto bg-info">Flex item 1</div>
<div class="p-2 bg-warning">Flex item 2</div>
<div class="p-2 bg-primary">Flex item 3</div>
</div>
Add auto margins to flex items with .ml-auto
, push items to left -
<div class="d-flex bg-secondary">
<div class="p-2 bg-info">Flex item 1</div>
<div class="p-2 bg-warning">Flex item 2</div>
<div class="p-2 ml-auto bg-primary">Flex item 3</div>
</div>
Controls the vertical alignment of gathered flex items.
align-content-start|end|center|between|around|stretch
: add with d-flex
for vertical alignment of gathered flex itemsNote : These classes have no effect on single rows of flex items.
<div class="d-flex flex-wrap align-content-start">..</div>
<div class="d-flex flex-wrap align-content-end">..</div>
Controls the vertical alignment of single rows of flex items.
align-items-start|end|center|baseline|stretch
: add with d-flex
for vertical alignment of single rows of flex items<div class="d-flex align-items-start">..</div>
<div class="d-flex align-items-end">..</div>
align-self-start|end|center|baseline|stretch
: add with d-flex
for vertical alignment of specified flex item<div class="d-flex bg-light" style="height:150px">
<div class="p-2 border">Flex item 1</div>
<div class="p-2 border align-self-start">Flex item 2</div>
<div class="p-2 border">Flex item 3</div>
</div>
Note : * = sm|md|lg|xl
d-*-flex
: creates flexbox container for different screensd-*-inline-flex
: ceates inline flexbox container for different screensflex-*-row
: display flex items horizontally on different screensflex-*-row-reverse
: display flex items horizontally, and right-aligned, on different screensflex-*-column
: display flex items vertically on different screensflex-*-column-reverse
: display flex items vertically, with reversed order, on different screens screensjustify-content-*-start
: display flex items from the start (left-aligned) on different screensjustify-content-*-end
: display flex items at the end (right-aligned) on different screensjustify-content-*-center
: display flex items in the center of flex container on different screensjustify-content-*-between
: display flex items in "between" on different screensjustify-content-*-around
: display flex items "around" on different screensflex-*-fill
: force flex items into equal widths on different screensflex-*-grow-0
: don't make items grow on different screensflex-*-grow-1
: make items grow on different screensflex-*-shrink-0
: don't make items shrink on diferent screensflex-*-shrink-1
: make items shrink on different screensorder-*-0-12
: change order from 0 to 12 on small screensflex-*-nowrap
: don't wrap items on different screensflex-*-wrap
: wrap items on different screensflex-*-wrap-reverse
: reverse wrapping of items on different screensalign-content-*-start
: align gathered items from start on different screensalign-content-*-end
: align gathered items at the end on different screensalign-content-*-center
: align gathered items in the center on different screensalign-content-*-around
: align gathered items "around" on different screensalign-content-*-stretch
: stretch gathered items on different screensalign-items-*-start
: align single rows of items from the start on different screensalign-items-*-end
: align single rows of items at the end on different screensalign-items-*-center
: align single rows of items in the center on different screensalign-items-*-baseline
: align single rows of items on the baseline on different screensalign-items-*-stretch
: stretch single rows of items on different screensalign-self-*-start
: align flex item from the start on different screensalign-self-*-end
: lign flex item at the end on different screensalign-self-*-center
: align flex item in the center on different screensalign-self-*-baseline
: align flex item on the baseline on different screensalign-self-*-stretch
: stretch flex item on different screensrow
: add to <div>
to create horizontal groups of columnscol
: add to <div>
inside .row
to create column (must be immediate childs of row)col-sm|md|lg|xl
: create responsive col - decide by us create equal of widthcol-sm|md|lg|xl-n
: responsive col that spans 1-12 rows (n = 1-12)no-gutters
: add with .row
to remove gutters (extra space)container
or container-fluid
.sm|md|lg|xl
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6"></div>
<div class="col-md-3"></div>
</div>
<div class="row">
<div class="col-*"></div>
<div class="col-*"></div>
<div class="col-*"></div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-sm-6">
<p>Lorem ipsum...</p>
</div>
<div class="col-sm-6">
<p>Sed ut perspiciatis...</p>
</div>
</div>
</div>
<div class="row">
<div class="col-sm">1 of 4</div>
<div class="col-sm">2 of 4</div>
<div class="col-sm">3 of 4</div>
<div class="col-sm">4 of 4</div>
</div>
<div class="row">
<div class="col-8">
col-8
<div class="row">
<div class="col-6">col-6</div>
<div class="col-6">col-6</div>
</div>
</div>
<div class="col-4">col-4</div>
</div>
Two cols of 25% 75% split on all devices (xsm, sm, md, lg, xl).
<div class="container-fluid">
<div class="row">
<div class="col-3 bg-success">
<p>Lorem ipsum...</p>
</div>
<div class="col-9 bg-warning">
<p>Sed ut perspiciatis...</p>
</div>
</div>
</div>
Two cols of 25% 75% split on sm (md, lg, xl) devices, on x-sm devices it will automatically stack 100% width.
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 bg-success">
<p>Lorem ipsum...</p>
</div>
<div class="col-sm-9 bg-warning">
<p>Sed ut perspiciatis...</p>
</div>
</div>
</div>
On sm size, look at classes with -sm-
in them and use those & on md size look at classes with -md-
in them and use those. 25% 75% split on sm devices & 50% 50% split on md (lg, xl)
devices. on x-sm devices, it will automatically stack (100%) -
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-6">
<p>Lorem ipsum...</p>
</div>
<div class="col-sm-9 col-md-6">
<p>Sed ut perspiciatis...</p>
</div>
</div>
</div>
Using Only Medium. md, lg, xl devices it split 50% 50%, for sm, x-sm devices it will stack vertically (100% width) -
<div class="row">
<div class="col-md-6">
<p>Lorem ipsum...</p>
</div>
<div class="col-md-6">
<p>Sed ut perspiciatis...</p>
</div>
</div>
On sm size, look at classes with -sm-
. on md size, look at classes with -md-
. on lg size, look at classes with -lg-
. 25% 75% split on sm devices, 50% 50% split on md devices
& 33% 66% split on lg & xl devices. On x-sm devices, it will automatically stack (100%) -
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-6 col-lg-4">
<p>Lorem ipsum...</p>
</div>
<div class="col-sm-9 col-md-6 col-lg-8">
<p>Sed ut perspiciatis...</p>
</div>
</div>
</div>
Using Only Large. lg & xl devices split 50% 50%, for md, sm & x-sm devices it will stack vertically (100% width) -
<div class="container-fluid">
<div class="row">
<div class="col-lg-6">
<p>Lorem ipsum...</p>
</div>
<div class="col-lg-6">
<p>Sed ut perspiciatis...</p>
</div>
</div>
</div>
25% 75% split on sm devices, 50% 50% split on md devices, 33% 66% split on lg & 20% 80% split on xl devices. On x-sm devices, it will automatically stack (100%) -
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-6 col-lg-4 col-xl-2">
<p>Lorem ipsum...</p>
</div>
<div class="col-sm-9 col-md-6 col-lg-8 col-xl-10">
<p>Sed ut perspiciatis...</p>
</div>
</div>
</div>
Using Only XLarge. On xl devices, split 50% 50%. For lg, md, sm, x-sm devices, it will stack vertically (100% width) -
<div class="row">
<div class="col-xl-6">
<p>Lorem ipsum...</p>
</div>
<div class="col-xl-6">
<p>Sed ut perspiciatis...</p>
</div>
</div>