Bootstrap 4 progress bar can be created by following ways:
.progress
class to parent container.
.progress-bar
class to inner container i.e child element of parent container having class .progress
.
Example
General Syntax
<div class="progress" style="height: 50px;">
<div class="progress-bar" style="width: 60%;">60%</div>
</div>
Source Code
<div class="container mt-4">
<div class="progress" style="height: 35px;">
<div class="progress-bar" style="width: 70%;">70%</div>
</div>
</div>
Source Code: Output
To set the height of the progress bar, use inline style sheet inside .progress
element and to set width of the progress bar use inline style sheet inside .progress-bar
element.
You can provide width and height of progress bar by using CSS. To set the height of the progress bar, use inline style sheet inside
.progress
element and to set width of the progress bar use inline style sheet inside .progress-bar
element.
To create progress-bar label, you have to write progress bar message inside progress bar i.e element containing .progress-bar
class.
Example
General Syntax
<div class="progress" style="height: 60px;">
<div class="progress-bar" style="width: 60%;">
Progress Bar Level(60%)
</div>
</div>
Source Code
<div class="container mt-4">
<div class="progress" style="height: 35px;">
<div class="progress-bar" style="width: 60%;">
60%
</div>
</div>
</div>
Source Code: Output
Remember: Write progress bar label information inside the <div>
having .progress-bar
.
Source Code
<div class="container mt-4">
<div class="progress" style="height: 30px;">
<div class="progress-bar" style="width: 50%;"></div>
</div>
</div>
Source Code: Output
Bootstrap striped progress bar can be created very easily by adding extra .progress-bar-striped
class to the .progress-bar
element.
Example
Source Code
<div class="container mt-4">
<div class="progress" style="height: 35px;">
<div class="progress-bar progress-bar-striped" style="width: 70%;"></div>
</div>
</div>
Source Code: Output
Attention:
To create striped progress bar add .progress-bar-striped
to the child element having .progress-bar
class.
Add .progress-bar-striped
class to the element having .progress-bar.progress-bar-striped
class.
Example
General Syntax
<element class="progress-bar progress-bar-striped progress-bar-animated"></element>
Source Code
<div class="container mt-4" style="height: 35px;">
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 70%;">70%</div>
</div>
Source Code: Output
Note: To create animated progress bar use,.progress-bar-animated
to the element having .progress-bar
class.
To create multiple progress bar, put multiple proress bar element having .progress-bar
class inside parent container having .progress
class.
Example
General Syntax
<div class="progress">
<div class="progress-bar bg-*">1</div>
<div class="progress-bar bg-*">2</div>
</div>
Source Code
<div class="progress mt-4" style="height: 40px;">
<div class="progress-bar bg-success" style="width: 40%;">
Success
</div>
<div class="progress-bar bg-danger" style="width: 20%;">
Danger
</div>
<div class="progress-bar bg-warning" style="width: 10%;">
Warning
</div>
</div>
Source Code: Output
Note: Multiple progress bar can be created by assigning multiple progress bar element inside the parent container having .progress
class.
To create a bootstrap 4 colored progress bar, you have to use Bootstrap 4, contextual background classes.
Source Code
<div class="progress mt-4" style="height: 35px;">
<div class="progress-bar" style="width: 10%;"></div>
</div>
<div class="progress" style="height: 35px;">
<div class="progress-bar bg-success" style="width: 20%;"></div>
</div>
Source Code: Output
Note:
Add followings background contextual classes to provide different color.These background contextual classes are:
.bg-success
,.bg-info
,.bg-warning
,.bg-danger
,.bg-white
,
.bg-secondary
,.bg-light
,.bg-dark