Animate Bootstrap progress bar


Follow the below given steps to create an animated progress bar:

  • Add a <div> with a class of .progress and .progress-striped. Also, add class .active to .progress-striped.
  • Next, inside the above <div>, add an empty <div> with a class of .progress-bar.
  • Add a style attribute with the width expressed as a percentage. Say for example, style = "60%"; indicates that the progress bar was at 60%.

You can try to run the following code to create animated progress bar −

Example

Live Demo

<!DOCTYPE html>
<html>
   <head>
      <title>Bootstrap Example</title>
      <link href = "/bootstrap/css/bootstrap.min.css" rel = "stylesheet">
      <script src = "/scripts/jquery.min.js"></script>
      <script src = "/bootstrap/js/bootstrap.min.js"></script>
   </head>
   <body>
      <h2>Progress Bar</h2>
      <h3>Normal Progress Bar</h3>
      <div class = "progress progress-striped">
         <div class = "progress-bar progress-bar-success" role = "progressbar"
            aria-valuenow = "45" aria-valuemin = "0" aria-valuemax = "100" style = "width: 45%;">
            <span class = "sr-only">45%Complete (success)</span>
         </div>
      </div>

      <h3>Animated Progress Bar</h3>
      <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>
   </body>
</html>

Updated on: 12-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements