Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Bootstrap Progress Bar

Bootstrap Progress Bar

This chapter will explain Bootstrap progress bars. In this tutorial, you will see how to use Bootstrap to create progress bars for loading, redirection, or action states.

Bootstrap progress bars use CSS3 transitions and animations to achieve this effect. Internet Explorer 9 and earlier versions and older Firefox do not support this feature, and Opera 12 does not support animations.

Default Progress Bar

The steps to create a basic progress bar are as follows:

Let's look at the example below; the .sr-only class can hide text content:

Example

<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style=">

width: 40%;

"

<span class="sr-only">

40% Complete

span

div

div

Try it »

The result is as follows:

You can also set text content inside the progress bar:

Example

<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="70" aria-valuemin="0" aria-valuemax="100" style="width:70%" 70%div div>

Try it »

The result is as follows:

Alternate Progress Bars

The steps to create progress bars of different styles are as follows:

Let's look at the example below:

Example

<div class="progress">
<div class=">

progress-bar progress-bar-success

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 90%;

"

<span class="sr-only">

90% Complete (Success)

span

div

div

<div class="progress">
<div class=">

progress-bar progress-bar-info

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 30%;

"

<span class="sr-only">

30% Complete (Info)

span

div

div

<div class="progress">
<div class=">

progress-bar progress-bar-warning

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 20%;

"

<span class="sr-only">

20% Complete (Warning)

span

div

div

<div class="progress">
<div class=">

progress-bar progress-bar-danger

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 10%;

"

<span class="sr-only">

10% Complete (Danger)

span

div

div

Try it »

The result is as follows:

Display progress bar text content:

Example

<div class="progress">
<div class=">

progress-bar progress-bar-success

"

role

=

"

progressbar

"

aria-valuenow

=

"

40

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width:40%

"

40% Complete (success)

div

div

<div class="progress">
<div class=">

progress-bar progress-bar-info

"

role

=

"

progressbar

"

aria-valuenow

=

"

50

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width:50%

"

50% Complete (info)

div

div

<div class="progress">
<div class=">

progress-bar progress-bar-warning

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width:60%

"

60% Complete (warning)

div

div

<div class="progress">
<div class=">

progress-bar progress-bar-danger

"

role

=

"

progressbar

"

aria-valuenow

=

"

70

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width:70%

"

70% Complete (danger)

div

div

Try it »

The result is as follows:

Striped Progress Bar

The steps to create a striped progress bar are as follows:

Let's look at the example below:

Example

<div class=">

progress progress-striped

"

<div class=">

progress-bar progress-bar-success

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 90%;

"

<span class="sr-only">

90% Complete (Success)

span

div

div

<div class=">

progress progress-striped

"

<div class=">

progress-bar progress-bar-info

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 30%;

"

<span class="sr-only">

30% Complete (Info)

span

div

div

<div class=">

progress progress-striped

"

<div class=">

progress-bar progress-bar-warning

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 20%;

"

<span class="sr-only">

20% Complete (Warning)

span

div

div

<div class=">

progress progress-striped

"

<div class=">

progress-bar progress-bar-danger

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 10%;

"

<span class="sr-only">

10% Complete (Danger)

span

div

div

Try it »

The result is as follows:

Animated Progress Bar

The steps to create an animated progress bar are as follows:

This will make the stripes appear to move from right to left.

Let's look at the example below:

Example

<div class=">

progress progress-striped active

"

<div class=">

progress-bar progress-bar-success

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 40%;

"

<span class="sr-only">

40% Complete

span

div

div

Try it »

The result is as follows:

Stacked Progress Bar

You can even stack multiple progress bars. Put multiple progress bars in the same .progress to achieve stacking, as shown in the example below:

Example

<div class="progress">
<div class=">

progress-bar progress-bar-success

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 40%;

"

<span class="sr-only">

40% Complete

span

div

<div class=">

progress-bar progress-bar-info

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 30%;

"

<span class="sr-only">

30% Complete (Info)

span

div

<div class=">

progress-bar progress-bar-warning

"

role

=

"

progressbar

"

aria-valuenow

=

"

60

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

style

=

"

width: 20%;

"

<span class="sr-only">

20% Complete (Warning)

span

div

div

Try it »

The result is as follows:


Progress Bar Size

We can set the size of the progress bar through the height property:

Example

<div class="progress" style=">

height: 1px;

"

<div class="progress-bar" role="progressbar" style=">

width: 25%;

"

aria-valuenow

=

"

25

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

div

div

<div class="progress" style=">

height: 20px;

"

<div class="progress-bar" role="progressbar" style=">

width: 25%;

"

aria-valuenow

=

"

25

"

aria-valuemin

=

"

0

"

aria-valuemax

=

"

100

"

div

div

Try it »

The result is as follows: