the title pretty much covers the problem I'm having.
I've a list on a website I'm developing and I have hidden things within collapsible elements.
The problem I have is that they are already collapsed on page load.
Does anyone have any idea on how to fix this?
Thanks.
How it works. The collapse JavaScript plugin is used to show and hide content. Buttons or anchors are used as triggers that are mapped to specific elements you toggle. Collapsing an element will animate the height from it's current value to 0 .
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 .
To control (show/hide) the collapsible content, add the data-toggle="collapse" attribute to an <a> or a <button> element. Then add the data-target="#id" attribute to connect the button with the collapsible content (<div id="demo">).
This can be done by setting the 'active' property of jQuery Accordion as false.
Thanks for your comment Rob.
Figured it after looking through the HTML, I need to use collapse
but all but one were using collapse in
(or collapse show
in bootstrap 4).
Problem sorted :)
Load collapsed on page load :
<div id="collapseOne" class="panel-collapse collapse in">
Load hidden until clicked :
<div id="collapseOne" class="panel-collapse collapse">
As of bootstrap 4.2.1 if we want to show the collapsed content on load:
use collapse show class to the div or any element you want to show.
check the docs Bootstrap Collapse
Bootstrap documentation says this:
The collapse plugin utilizes a few classes to handle the heavy lifting:
.collapse
hides the content
.collapse.in
shows the content
.collapsing
is added when the transition starts, and removed when it finishes
Edit your HTML accordingly (use collapse.in instead of collapse)
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