Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Accordion - How to print with all expanded?

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.

like image 668
cardiac7 Avatar asked Jan 11 '13 15:01

cardiac7


People also ask

How do you make an accordion not collapse?

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!

How do I keep my Bootstrap accordion open?

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.

How does Bootstrap accordion work?

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.


2 Answers

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;
    }
}
like image 38
Tadeck Avatar answered Oct 08 '22 22:10

Tadeck


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;
}
like image 65
b3ko Avatar answered Oct 08 '22 21:10

b3ko