Keep caption with table but allow table to break

This forum is for all Flare issues related to styles, stylesheets and XML.

Keep caption with table but allow table to break

Postby oceanclub on Mon Apr 08, 2019 8:21 am

Hi all,

Is it possible to satisfy the following conditions:

* Allow a table to break across pages
* Always keep a table caption (below the table) with the table (so, if the caption would be on its own on a page, include the last row of the table with the caption on the same page)

I initially applied page-break-inside: avoid to a div tag surrounding the table and caption. But if the table was longer than a page, it started on a new page.

I then tried page-break-before: avoid on the caption itself. But if the table went to the end of a page, the caption was placed on the next page.

Any help appreciated,

Paul
User avatar
oceanclub
Sr. Propeller Head
 
Posts: 183
Joined: Thu Oct 10, 2013 4:45 am
Location: Dublin

Re: Keep caption with table but allow table to break

Postby devjoe on Thu Apr 11, 2019 7:50 am

I am surprised page-break-before: avoid; on the caption element does not work. But maybe try to use a complex selector:

tr:last-of-type {
page-break-after: avoid;
}

This will apply the page break formatting to the last table row, which you can additionally specify to be tables of a certain class [ones expected to have captions].

You might also try to generate a help output with the same settings as your print output and use the inspect feature in the browser to see if there is anything else getting in there between the table and the caption that is messing things up, and to make sure the CSS style is actually being applied to the caption.
devjoe
Sr. Propeller Head
 
Posts: 312
Joined: Thu Jan 23, 2014 1:43 pm

Re: Keep caption with table but allow table to break

Postby oceanclub on Tue May 07, 2019 9:37 am

devjoe wrote:I am surprised page-break-before: avoid; on the caption element does not work. But maybe try to use a complex selector:

tr:last-of-type {
page-break-after: avoid;
}

This will apply the page break formatting to the last table row, which you can additionally specify to be tables of a certain class [ones expected to have captions].

You might also try to generate a help output with the same settings as your print output and use the inspect feature in the browser to see if there is anything else getting in there between the table and the caption that is messing things up, and to make sure the CSS style is actually being applied to the caption.


I've tried several variations on this with no luck. I even create a class style named tr.last-of-type with the following definition and applied it to the last row (using styling just to make sure the class style is taking effect):

Code: Select all
   tr.last-of-type
   {   
   font-weight: bold;
   background-color: #bde9ba;
   page-break-after: avoid;
   }


The last row does have the relevant bold/colors styling - so the class style is definitely being applied - but there is still a page break after if it is the last row on screen (the caption again falls on the next screen).
User avatar
oceanclub
Sr. Propeller Head
 
Posts: 183
Joined: Thu Oct 10, 2013 4:45 am
Location: Dublin


Return to Styles, Stylesheets and XML

Who is online

Users browsing this forum: No registered users and 3 guests