I am using the Twitter Bootstrap accordions here and there throughout my site. They work great and all that, the issue I just noticed is if I want to Print a page with one on it. Ideally they should all expand if the page is to be printed for my purposes.
Does anyone know the best way to go about this? I know I could hookup something via javascript to a Print button on the page, but let's assume that the user will use the browser's Print button - so tying javascript to this may not be an option.
Your child Accordion items aren't collapsing because you're setting data-parent to their own individual boxes. If you apply an ID of accordion-sub to . panel-body and then change your data-parent to match you'll achieve something functional. I followed your example and it works a treat!
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.
When you use the accordion in Bootstrap, the point is to wrap the cards in an element with an individual ID, and then target this element as the data-parent of the collapsibles by referring to the id . Using this simple addition, you can make your content display more interactively.
Use CSS media types and just style all of accordions as expanded, if the media is for printing.
Small example here, expands all accordions only for printing:
@media print {
/* your stylesheet for printing, eg.: */
.accordion-group .accordion-body.collapse {
height: auto;
}
}
i am using bootstrap 3.1.1 and the bootstrap.css as it comes by default. i am also using the example accordion html from this page: http://getbootstrap.com/javascript/#collapse
and for me adding this rule to the @media print {..} section of the .css file did the trick:
.collapse {
display: block !important;
height: auto !important;
}
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