Progress Bars

What is progress bar?
  • The purpose of progress bars is to show that assets are loading, in progress, or that there is action taking place regarding elements on the page.
  • These features are not supported in Internet Explorer 9 and below or older versions of Firefox.
  • Opera 12 does not support animations

Default Progress Bar

  • Use <div> tag with class of .progress
  • Inside the empty <div> tag to create another <div> tag with a class of .progress-bar
  • To define the style attributes with the width expressed as a percentage(for example style=”60%”)
  • That 60% indicates the progress bar level
Sample program for Default Progress Bar
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Progress Bar
  13. </h1>
  14. </div>
  15. <div class="row">
  16. <div class = "progress">
  17. <div class = "progress-bar" role = "progressbar" aria-valuenow = "60"
  18. aria-valuemin = "0" aria-valuemax = "100" style = "width: 40%;">
  19. <span class = "sr-only">40% Complete</span>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  25. <script type="text/css" src="js/jquery"></script>
  26. </body>
  27. </html>

Output
Output

Colored Progress Bar

There are four different colors using what is given below,

  • .progress-bar-success
  • .progress-bar-info
  • .progress-bar-warning
  • .progress-bar-danger

Alternate Progress Bar

  • This alternative progress bar is used to indicate different types in different style and various levels
  • Use <div> tag with class of .progress
  • Inside the empty <div> tag create another <div> tag with a class of .progress-bar where could be success,info,warning,danger
  • To define the style attributes with the width expressed as a percentage(for example style=”60%”)
  • That 60% indicates the progress bar level

Sample program for alternate progress bar

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Progress Bar
  13. </h1>
  14. </div>
  15. <div class="row"> Alternateprogress-bar
  16. <div class = "progress">
  17. <div class = "progress-bar progress-bar-success"
  18. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 90%;">
  19. <span class = "sr-only">90% Complete (Sucess)</span>
  20. </div>
  21. </div>
  22. <div class = "progress">
  23. <div class = "progress-bar progress-bar-info"
  24. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 30%;">
  25. <span class = "sr-only">30% Complete (info)</span>
  26. </div>
  27. </div>
  28. <div class = "progress">
  29. <div class = "progress-bar progress-bar-warning"
  30. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 20%;">
  31. <span class = "sr-only">20%Complete (warning)</span>
  32. </div>
  33. </div>
  34. <div class = "progress">
  35. <div class = "progress-bar progress-bar-danger"
  36. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 10%;">
  37. <span class = "sr-only">10% Complete (danger)</span>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  43. <script type="text/css" src="js/jquery"></script>
  44. </body>
  45. </html>

Output
Output

Striped Progress Bar

  • This striped progress bar is comes with zebra striper
  • If we have success,info,warning,danger color progress bars inside the progress bar zebra designed lines are generated
  • Thai is used for some advanced progress bars

Sample program for Striped Progress Bar

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Progress Bar
  13. </h1>
  14. </div>
  15. <div class="row"> Striped progress-bar
  16. <div class = "progress progress-striped">
  17. <div class = "progress-bar progress-bar-success"
  18. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 90%;">
  19. <span class = "sr-only">90% Complete (Sucess)</span>
  20. </div>
  21. </div>
  22. <div class = "progress progress-striped">
  23. <div class = "progress-bar progress-bar-info"
  24. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 30%;">
  25. <span class = "sr-only">30% Complete (info)</span>
  26. </div>
  27. </div>
  28. <div class = "progress progress-striped">
  29. <div class = "progress-bar progress-bar-warning"
  30. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style="width: 20%;">
  31. <span class = "sr-only">20%Complete (warning)</span>
  32. </div>
  33. </div>
  34. <div class = "progress progress-striped">
  35. <div class = "progress-bar progress-bar-danger" role = "progressbar"
  36. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 10%;">
  37. <span class = "sr-only">10% Complete (danger)</span>
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  43. <script type="text/css" src="js/jquery"></script>
  44. </body>
  45. </html>
Output
Output
Animated Progress Bar
  • This progress bar animates the strips from the right to left side
  • It looks like the strips are moving
  • The animated progress bar is continuously moving from the right to left side

Sample program for Animated Progress Bar

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Progress Bar
  13. </h1>
  14. </div>
  15. <div class="row"> Animated progress-bar
  16. <div class = "progress progress-striped active">
  17. <div class = "progress-bar progress-bar-success"
  18. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 40%;">
  19. <span class = "sr-only">40% Complete</span>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  25. <script type="text/css" src="js/jquery"></script>
  26. </body>
  27. </html>
Output
Output
Stacked Progress Bar
  • Stacked multiple progress bar
  • Place the multiple progress bars into the same .progress to stack
  • Single strip has multiple stacked bars

Sample program for stacked progress bar

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Progress Bar
  13. </h1>
  14. </div>
  15. <div class="row"> Stacked progress-bar
  16. <div class = "progress">
  17. <div class = "progress-bar progress-bar-success"
  18. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 40%;">
  19. <span class = "sr-only">40% Complete</span>
  20. </div>
  21. <div class = "progress-bar progress-bar-info"
  22. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 30%;">
  23. <span class = "sr-only">30% Complete (info)</span>
  24. </div>
  25. <div class = "progress-bar progress-bar-warning"
  26. aria-valuenow = "60" aria-valuemin = "0" aria-valuemax = "100" style = "width: 20%;">
  27. <span class = "sr-only">20%Complete (warning)</span>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  33. <script type="text/css" src="js/jquery"></script>
  34. </body>
  35. </html>
Output
Output

Bootstrap Alerts

  • Bootstrap provides an easy way to create predefined alert messages
  • Success - successful or positive action.
  • Info - neutral informative change or action.
  • Warning - warning that might need attention.
  • Danger - dangerous or potentially negative action.

Bootstrap Alerts classes

The alert creates the .alert class,

  • Alert-success
  • Alert-info
  • Alert-warning
  • Alert-danger

Sample program for bootstrap alert classes

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Alert
  13. </h1>
  14. </div>
  15. <div class="row">
  16. <div class="alert alert-success">
  17. <strong>Success-</strong> successful or positive action.
  18. </div>
  19. <div class="alert alert-info">
  20. <strong>Info-</strong> neutral informative change or action.
  21. </div>
  22. <div class="alert alert-warning">
  23. <strong>Warning-</strong>warning that might need attention.
  24. </div>
  25. <div class="alert alert-danger">
  26. <strong>Danger-</strong>dangerous or potentially negative action.
  27. </div>
  28. </div>
  29. </div>
  30. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  31. <script type="text/css" src="js/jquery"></script>
  32. </body>
  33. </html>
Output
Output
Alert link
  • .alert-link to any links inside the alert box to create matching colored link
  • In the alert message a link is included

Sample program for alert link

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Alert
  13. </h1>
  14. </div>
  15. <div class="row">
  16. <div class="alert alert-success">
  17. <strong>Success-</strong> You should <a href="#" class="alert-link">read this message</a>.
  18. </div>
  19. <div class="alert alert-info">
  20. <strong>info-</strong> You should <a href="#" class="alert-link">read this message</a>.
  21. </div>
  22. <div class="alert alert-warning">
  23. <strong>Warning-</strong> You should <a href="#" class="alert-link">read this message</a>.
  24. </div>
  25. <div class="alert alert-danger">
  26. <strong>Danger-</strong> You should <a href="#" class="alert-link">read this message</a>.
  27. </div>
  28. </div>
  29. </div>
  30. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  31. <script type="text/css" src="js/jquery"></script>
  32. </body>
  33. </html>
Output
Output
Closing Alert
  • The right side of the alert container has X symbol
  • .alert-dismissable class in to the alert container
  • Add class=”close” and data-dismiss=”alert” to a link or button element

Sample program for closing alert

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Alert
  13. </h1>
  14. </div>
  15. <div class="row">
  16. Example
  17. <div class="alert alert-success alert-dismissable">
  18. <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
  19. <strong>Success!</strong> Indicates a successful or positive action.
  20. </div>
  21. </div>
  22. </div>
  23. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  24. <script type="text/css" src="js/jquery"></script>
  25. </body>
  26. </html>
Output
Output

Animated alert
  • The X symbol to the right will ”fade” out
  • The .fade and .in class adds a fading effect when closing the alert message

Sample program for animated alert

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Alert
  13. </h1>
  14. </div>
  15. <div class="row">
  16. <div class="alert alert-danger fade in">
  17. </div>
  18. </div>
  19. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  20. <script type="text/css" src="js/jquery"></script>
  21. </body>
  22. </html>
Output
Output

Bootstrap Labels

  • Labels are used to provide additional information about something
  • Use .label class

Sample program for labels

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Labels
  13. </h1>
  14. <h1>Diamond<span class="label label-default">Stone</span></h1>
  15. <h2>Gold <span class="label label-default">metal</span></h2>
  16. <h3>Silver<span class="label label-default">metal</span></h3>
  17. <h4>Platinum <span class="label label-default">metal</span></h4>
  18. <h5>Pearl <span class="label label-default">non-metal</span></h5>
  19. <h6>Ruby <span class="label label-default">metal</span></h6>
  20. </div>
  21. </div>
  22. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  23. <script type="text/css" src="js/jquery"></script>
  24. </body>
  25. </html>

Output
Output

Contextual label classes

There are six contextual label classes available which are given below with a span element to create a lable,

  • .label-default
  • .label-primary
  • .label-success
  • .label-info
  • .label-warning
  • .label-danger

Sample program for Contextual label classes

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial scale=1">
  6. <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
  7. </head>
  8. <body>
  9. <div class="container">
  10. <div class="row">
  11. <h1 class="text-center page-header text-info">
  12. Bootstrap Labels
  13. </h1>
  14. <span class="label label-default">Default</span>
  15. <span class="label label-primary">Primary</span>
  16. <span class="label label-success">Success</span>
  17. <span class="label label-info">Info</span>
  18. <span class="label label-warning">Warning</span>
  19. <span class="label label-danger">Danger</span>
  20. </div>
  21. </div>
  22. <script type="text/javascript" src="js/bootstrap.min.js"></script>
  23. <script type="text/css" src="js/jquery"></script>
  24. </body>
  25. </html>
Output
Output
These are the Sample programs and outputs for Labels

Conclusion

I hope now you can understand how to use and create the Bootstrap - Progress Bars, Alert, Labels. In the future we can learn about the Bootstrap techniques step by step. Stay tuned.