Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you keep multiple collapses open in Bootstrap 3?

Bootstrap normally closes other collapses when you click on one to open it.

Is there an option or hack to make it keep the collapses open unless explicitly closed without changing the look and layout of the panel-group?

like image 247
trusktr Avatar asked Apr 06 '14 05:04

trusktr


Video Answer


2 Answers

Update 2020

Bootstrap 4

How do you make Twitter Bootstrap Accordion keep one group open?

Bootstrap 3

You can just remove the data-parent attribute that is normally used in the accordion markup.

<div class="panel-group" id="accordion">   <div class="panel panel-default">     <div class="panel-heading">       <h4 class="panel-title">         <a class="accordion-toggle" data-toggle="collapse" href="#collapseOne">           Collapsible Group Item #1         </a>       </h4>     </div>      ...  

http://bootply.com/127843

like image 109
Zim Avatar answered Sep 28 '22 09:09

Zim


See this demo: http://plnkr.co/edit/OxbVII?p=preview

Idea:

Just add data-toggle="collapse" and a data-target to element, to automatically assign control of a collapsible element. The data-target attribute accepts a CSS selector to apply the collapse to. Be sure to add the class collapse to the collapsible element. If you'd like it to default open, add the additional class in.

like image 38
Arpit Srivastava Avatar answered Sep 28 '22 07:09

Arpit Srivastava