All for Joomla All for Webmasters

Bootstrap Buttons

There are seven styles to add a button in Bootstrap. Use the following classes to achieve the different button styles:

  • .btn-default
  • .btn-primary
  • .btn-success
  • .btn-info
  • .btn-warning
  • .btn-danger
  • .btn-link

Bootstrap Button Example: specifying seven styles

  1.   <!DOCTYPE html>
  2. <html lang=“en”>
  3.   <head>
  4.      <title>Job</title>
  5.      <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”/>
  6.   </head>
  7.   <body>
  8.     <h1>Button Example!</h1>
  9. <button class=“btn btn-default”>default</button>
  10. <button class=“btn btn-primary”>primary</button>
  11. <button class=“btn btn-danger”>danger</button>
  12. <button class=“btn btn-success”>success</button>
  13. <button class=“btn btn-info”>info</button>
  14. <button class=“btn btn-warning”>warning</button>
  15. <button class=“btn btn-link”>Link</button>
  16. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>
  17.   <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script>
  18.   </body>
  19. </html>

Bootstrap Button Size

In Bootstrap, you can choose a button according to your requirement. It provides four button sizes.

The following classes define the different sizes:

  • .btn-lg
  • .btn-md
  • .btn-sm
  • .btn-xs

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.   <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  9.   <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  10. </head>
  11. <body>
  12. <div class=“container”>
  13.   <h2>Button Sizes</h2>
  14.   <button type=“button” class=“btn btn-primary btn-lg”>Large</button>
  15.   <button type=“button” class=“btn btn-primary btn-md”>Medium</button>
  16.   <button type=“button” class=“btn btn-primary btn-sm”>Small</button>
  17.   <button type=“button” class=“btn btn-primary btn-xs”>XSmall</button>
  18. </div>
  19. </body>
  20. </html>

Bootstrap Enable/Disable Buttons

You can set a button disable or unclickable state.

The .active class is used to make a button appear pressed, and the class .disabled makes a button unclickable:

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.   <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  9.   <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  10. </head>
  11. <body>
  12. <div class=“container”>
  13.   <h2>Button States</h2>
  14.   <button type=“button” class=“btn btn-primary”>Primary Button</button>
  15.   <button type=“button” class=“btn btn-primary active”>Active Primary</button>
  16.   <button type=“button” class=“btn btn-primary disabled”>Disabled Primary</button>
  17. </div>
  18. </body>
  19. </html>

Bootstrap Block level buttons

The block level button covers the entire width of the parent element.

The .btn-block class is used to create a block level button:

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.   <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  9.   <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  10. </head>
  11. <body>
  12. <div class=“container”>
  13.   <h2>Block Level Buttons</h2>
  14.   <button type=“button” class=“btn btn-primary btn-block”>Button 1</button>
  15.   <button type=“button” class=“btn btn-default btn-block”>Button 2</button>
  16.   <h2>Large Block Level Buttons</h2>
  17.   <button type=“button” class=“btn btn-primary btn-lg btn-block”>Button 1</button>
  18.   <button type=“button” class=“btn btn-default btn-lg btn-block”>Button 2</button>
  19.   <h2>Small Block Level Buttons</h2>
  20.   <button type=“button” class=“btn btn-primary btn-sm btn-block”>Button 1</button>
  21.   <button type=“button” class=“btn btn-default btn-sm btn-block”>Button 2</button>
  22. </div>
  23. </body>
  24. </html>
PinIt
submit to reddit

Leave a Reply

Top