All for Joomla All for Webmasters

Bootstrap Badges and Labels

Bootstrap Badges

Bootstrap Badges are numerical indicators used to show that how many items are associated with the specific link. Badges are used to highlight new or unread items.

The class .badge within the <span> element is used to create badges.

Bootstrap Badge Example

  1.  <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Example</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Badges</h2>
  12.   <a href=“#”>News <span class=“badge”>5</span></a><br>
  13.   <a href=“#”>Comments <span class=“badge”>10</span></a><br>
  14.   <a href=“#”>Updates <span class=“badge”>2</span></a>
  15. </div>
  16.  <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  17.   <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  18. </body>
  19. </html>

Bootstrap Badge Example 2

You can also use badges inside other elements, such as buttons.

Let’s take an example to see how to add badges to button.

  1.  <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Example</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Badges on Buttons</h2>
  12.   <button type=“button” class=“btn btn-primary”>Primary <span class=“badge”>7</span></button>
  13.   <button type=“button” class=“btn btn-success”>Success <span class=“badge”>3</span></button>
  14.   <button type=“button” class=“btn btn-danger”>Danger <span class=“badge”>5</span></button>
  15. </div>
  16. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  17. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  18. </body>
  19. </html>

Bootstrap Labels

Bootstrap labels are used to specify the additional information about something like offering counts, tips, or other makeup for pages.

The class .label is used to display the labels.


Bootstrap Label Example

  1.  <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Label Example</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Labels Example</h2>
  12.   <h1>Update <span class=“label label-default”>New</span></h1>
  13.   <h2>Update<span class=“label label-default”>New</span></h2>
  14.   <h3>Update <span class=“label label-default”>New</span></h3>
  15.   <h4>Update<span class=“label label-default”>New</span></h4>
  16.   <h5>Update<span class=“label label-default”>New</span></h5>
  17.   <h6>Update<span class=“label label-default”>New</span></h6>
  18. </div>
  19. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  20. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  21. </body>
  22. </html>

Bootstrap Label Example 2: changing colors

We can change the label colors by using contextual label classes.

  1.  <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Contextual Label</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Contextual Label Classes</h2>
  12.   <span class=“label label-default”>Default Label</span>
  13.   <span class=“label label-primary”>Primary Label</span>
  14.   <span class=“label label-success”>Success Label</span>
  15.   <span class=“label label-info”>Info Label</span>
  16.   <span class=“label label-warning”>Warning Label</span>
  17.   <span class=“label label-danger”>Danger Label</span>
  18. </div>
  19. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  20. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  21. </body>
  22. </html>

 


Bootstrap Label Example 3

  1. <!DOCTYPE html>
  2. <html lang=“en”>
  3. <head>
  4.   <title>Bootstrap Case</title>
  5.   <meta charset=“utf-8”>
  6.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  7.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  8. </head>
  9. <body>
  10. <div class=“container”>
  11.   <h2>Labels Example</h2>
  12.   <h3>Update <span class=“label label-default”>new</span>
  13.   <h3>Update <span class=“label label-primary”>new</span>
  14.   <h3>Update <span class=“label label-success”>new</span>
  15.   <h3>Update <span class=“label label-info”>new</span>
  16.   <h3>Update <span class=“label label-warning”>new</span>
  17.   <h3>Update <span class=“label label-danger”>new</span>
  18. </div>
  19. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  20. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  21. </body>
  22. </html>
PinIt
submit to reddit

Leave a Reply

Top