All for Joomla All for Webmasters

Bootstrap Panels

In Bootstrap, a panel is a bordered box with some padding around its element. The panel components are used when you want to put your DOM component in a box.

The class .panel is used within the <div> element to create Bootstrap panels. The content inside the panel has a .panel-body class.

Generally a panel contains three parts:

  • Panel header
  • Panel content
  • Panel footer

Bootstrap Panel Example

  1. <!DOCTYPE html>
  2. <html lang=“en”>
  3.   <head>
  4.      <title>Panel</title>
  5.      <link rel=“stylesheet” href=“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”/>
  6.   </head>
  7.   <body>
  8. <div class=“container”>
  9.   <h1>Panel Example</h1>
  10. <div class=“panel panel-primary”>
  11.   <div class=“panel-heading”>
  12.     <h3 class=“panel-title”><strong>Panel title</strong></h3>
  13.   </div>
  14.   <div class=“panel-body”>
  15.     Panel content
  16.   </div>
  17.   <div class=“panel-footer”>
  18.     <strong>Panel footer</strong>
  19.   </div>
  20. </div>
  21. </div>
  22. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script>
  23.   <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js”></script>
  24.   </body>
  25. </html>

Bootstrap Panel Group

Panel group is used to groups many panel together.

For a panel group, you have to wrap a <div> with class .panel-group around them.

The .panel-group class clears the bottom-margin of each panel.

See this example:

  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.   <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>Panel Group</h2>
  14.   <p>The panel-group class clears the bottom-margin. Try to remove the class and see what happens.</p>
  15.   <div class=“panel-group”>
  16.     <div class=“panel panel-default”>
  17.       <div class=“panel-heading”>Panel Header</div>
  18.       <div class=“panel-body”>Panel Content</div>
  19.     </div>
  20.     <div class=“panel panel-default”>
  21.       <div class=“panel-heading”>Panel Header</div>
  22.       <div class=“panel-body”>Panel Content</div>
  23.     </div>
  24.     <div class=“panel panel-default”>
  25.       <div class=“panel-heading”>Panel Header</div>
  26.       <div class=“panel-body”>Panel Content</div>
  27.     </div>
  28.   </div>
  29. </div>
  30. </body>
  31. </html>

Bootstrap Panel with contextual classes

Contextual classes (.panel-default, .panel-primary, .panel-success, .panel-info, .panel-warning, or .panel-danger) are used to color the panels.

Example:

  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.   <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>Panels with Contextual Classes</h2>
  14.   <div class=“panel-group”>
  15.     <div class=“panel panel-default”>
  16.       <div class=“panel-heading”>Panel with panel-default class</div>
  17.       <div class=“panel-body”>Panel Content</div>
  18.     </div>
  19.     <div class=“panel panel-primary”>
  20.       <div class=“panel-heading”>Panel with panel-primary class</div>
  21.       <div class=“panel-body”>Panel Content</div>
  22.     </div>
  23.     <div class=“panel panel-success”>
  24.       <div class=“panel-heading”>Panel with panel-success class</div>
  25.       <div class=“panel-body”>Panel Content</div>
  26.     </div>
  27.     <div class=“panel panel-info”>
  28.       <div class=“panel-heading”>Panel with panel-info class</div>
  29.       <div class=“panel-body”>Panel Content</div>
  30.     </div>
  31.     <div class=“panel panel-warning”>
  32.       <div class=“panel-heading”>Panel with panel-warning class</div>
  33.       <div class=“panel-body”>Panel Content</div>
  34.     </div>
  35.     <div class=“panel panel-danger”>
  36.       <div class=“panel-heading”>Panel with panel-danger class</div>
  37.       <div class=“panel-body”>Panel Content</div>
  38.     </div>
  39.   </div>
  40. </div>
  41. </body>
  42. </html>
PinIt
submit to reddit

Leave a Reply

Top