I'd like to collapse and show two columns when a link is clicked.
I've wrapped the two columns in a div
, which has an id referenced by the link in the column above it. The first column takes the full width of the page, and the second and third should split the page or stack. All three columns are wrapped in a div.row
, and the rows repeat down the page.
It seems that the collapse animation works for rows that have a border. However, the opening transition "jumps" back up. If I remove the border on the row and click on the link, there is a delay before the two columns just abruptly appear.
I want neither of these things to happen. I'd like a smooth transition revealing the two columns when the link is clicked. How can I make that happen?
<div class='container'>
<div class='row' style='border-bottom: 1px solid #ddd;'>
<div class='col-xs-12'>
<a data-toggle='collapse' href='#details1'>Open or close details</a>
</div>
<div class='collapse' id='details1'>
<div class='col-sm-6'>
<table class='table table-bordered table-condensed'>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
</table>
</div>
<div class='col-sm-6'>
<b>Hello world</b>
</div>
</div>
</div>
<div class='row'>
<div class='col-xs-12'>
<a data-toggle='collapse' href='#details2'>Open or close details (row with no border)</a>
</div>
<div class='collapse' id='details2'>
<div class='col-sm-6'>
<table class='table table-bordered table-condensed'>
<tr>
<td>Hello</td>
<td>World</td>
</tr>
</table>
</div>
<div class='col-sm-6'>
<b>Hello world</b>
</div>
</div>
</div>
</div>
JSFiddle.
Methods 1 .collapse ('toggle') Toggles a collapsible element to shown or hidden. 2 .collapse ('show') Shows a collapsible element. 3 .collapse ('hide') Hides a collapsible element. 4 .collapse ('dispose') Destroys an element’s collapse. Bootstrap’s collapse class exposes a few events for hooking into collapse functionality.
Example Explained. The .collapse class indicates a collapsible element (a <div> in our example); this is the content that will be shown or hidden with a click of a button. To control (show/hide) the collapsible content, add the data-toggle="collapse" attribute to an <a> or a <button> element.
Introduction of Wrap Bootstrap The bootstrap wrap is used to cover or wrap the flex items in a flex container.It has main three classes which is.flex-wrap,.flex-nowrap,.flex-wrap-reverse.First is.flex-wrap for wrapping flax content. Second is.flex-nowrap for no wrapping in flex container.
The .collapse class indicates a collapsible element (a <div> in our example); this is the content that will be shown or hidden with a click of a button. To control (show/hide) the collapsible content, add the data-toggle=collapse attribute to an <a> or a <button> element.
Got it! The wrapper div needs to be set so that its height equals the maximum height of its children (so Bootstrap knows how much to expand). From Make outer div be automatically the same height as its floating content, this somehow works (!?)
.details {
overflow: hidden;
clear: both;
}
where div.details
is the wrapper div containing the two columns. See the JSFiddle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With