All for Joomla All for Webmasters

Bootstrap Collapse

Bootstrap collapse is used when you want to hide and show large amount of content.

The “.collapse” class is used to specify the collapsible element.

Bootstrap Collapse Example

  1.  <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  5.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  6. </head>
  7. <body>
  8. <div class=“container”>
  9.   <h2>Basic Collapse Example</h2>
  10.   <button type=“button” class=“btn btn-info” data-toggle=“collapse” data-target=“#demo”>Simple collapsible</button>
  11.   <div id=“demo” class=“collapse”>
  12. Tigers and Lions are the most ferocious animals on the earth. They belong to the felidae(cat) family.
  13. They are both from the four big cats. These four big cats are Lion, Tiger, Leopard, and Jaguar.
  14.  These animals reside on the top of the food chain and don’t have any predators.
  15.   </div>
  16. </div>
  17. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  18. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  19. </body>
  20. </html>

 

Bootstrap Collapsible Panel

You can also collapse a panel.

See this example:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  5.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  6. </head>
  7. <body>
  8. <div class=“container”>
  9.   <h2>Collapsible Panel</h2>
  10.   <div class=“panel-group”>
  11.     <div class=“panel panel-default”>
  12.       <div class=“panel-heading”>
  13.         <h4 class=“panel-title”>
  14.           <a data-toggle=“collapse” href=“#collapse1”>Collapsible panel</a>
  15.         </h4>
  16.       </div>
  17.       <div id=“collapse1” class=“panel-collapse collapse”>
  18.         <div class=“panel-body”>Panel Body</div>
  19.         <div class=“panel-footer”>Panel Footer</div>
  20.       </div>
  21.     </div>
  22.   </div>
  23. </div>
  24. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  25. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  26. </body>
  27. </html>

 

Bootstrap Collapsible List Group

You can also create a collapsible panel with a list group inside.

See this example:

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta name=“viewport” content=“width=device-width, initial-scale=1”>
  5.   <link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”>
  6. </head>
  7. <body>
  8. <div class=“container”>
  9.   <h2>Collapsible List Group</h2>
  10.   <div class=“panel-group”>
  11.     <div class=“panel panel-default”>
  12.       <div class=“panel-heading”>
  13.         <h4 class=“panel-title”>
  14.           <a data-toggle=“collapse” href=“#collapse1”>Collapsible list group</a>
  15.         </h4>
  16.       </div>
  17.       <div id=“collapse1” class=“panel-collapse collapse”>
  18.         <ul class=“list-group”>
  19.           <li class=“list-group-item”>One</li>
  20.           <li class=“list-group-item”>Two</li>
  21.           <li class=“list-group-item”>Three</li>
  22.         </ul>
  23.         <div class=“panel-footer”>Footer</div>
  24.       </div>
  25.     </div>
  26.   </div>
  27. </div>
  28. <script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js”></script>
  29. <script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>
  30. </body>
  31. </html>
PinIt
submit to reddit

Leave a Reply

Top