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

<!DOCTYPE html>  

<html>  

<head>  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Basic Collapse Example</h2>  

  <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#demo">Simple collapsible</button>  

  <div id="demo" class="collapse">  

Tigers and Lions are the most ferocious animals on the earth. They belong to the felidae(cat) family.   

They are both from the four big cats. These four big cats are Lion, Tiger, Leopard, and Jaguar.  

 These animals reside on the top of the food chain and don't have any predators.  

  </div>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>  

</body>  

</html>  

Bootstrap Collapsible Panel

You can also collapse a panel.

See this example:

<!DOCTYPE html>  

<html>  

<head>  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Collapsible Panel</h2>  

  <div class="panel-group">  

    <div class="panel panel-default">  

      <div class="panel-heading">  

        <h4 class="panel-title">  

          <a data-toggle="collapse" href="#collapse1">Collapsible panel</a>  

        </h4>  

      </div>  

      <div id="collapse1" class="panel-collapse collapse">  

        <div class="panel-body">Panel Body</div>  

        <div class="panel-footer">Panel Footer</div>  

      </div>  

    </div>  

  </div>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>     

</body>  

</html>

Bootstrap Collapsible List Group

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

See this example:

<!DOCTYPE html>  

<html>  

<head>  

  <meta name="viewport" content="width=device-width, initial-scale=1">  

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">  

    

</head>  

<body>  

  

<div class="container">  

  <h2>Collapsible List Group</h2>  

  <div class="panel-group">  

    <div class="panel panel-default">  

      <div class="panel-heading">  

        <h4 class="panel-title">  

          <a data-toggle="collapse" href="#collapse1">Collapsible list group</a>  

        </h4>  

      </div>  

      <div id="collapse1" class="panel-collapse collapse">  

        <ul class="list-group">  

          <li class="list-group-item">One</li>  

          <li class="list-group-item">Two</li>  

          <li class="list-group-item">Three</li>  

        </ul>  

        <div class="panel-footer">Footer</div>  

      </div>  

    </div>  

  </div>  

</div>  

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>  

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>      

</body>  

</html> 

    Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *