06-04-2021, 09:49 AM | #1 |
Addict
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
|
epub 2 pdf widowed <h2> solution sought
It is my understanding that GTK does not honor widows because of "columns". I do not understand the ins and outs of the technicalities. I find <h2>heading</h2> at the bottom of pdf pages. When I designate break-inside: avoid this only treats the <h2> tag itself and, of course, does not break, but it is still at page bottom. If I wrap the <h2> pair and the following <p> tag with a <div> I can tell the <div> not to break and that works okay. But it is laborious to go through and do this manually for every <h2>. To avoid adding divs throughout the book I tried to 'group' with a combinator in a goofy way: <style>(h2+*) {page-break-inside: avoid}</style>. That does not work. I cannot see using :before, :after, :first-pudknocker, or anything else. To say it cutesy-wootsie, I am looking for a way to affect 'the antecedent of an adjacent sibling selector of a combinator'. Would appreciate input. Best regards, Pop
|
06-04-2021, 10:21 AM | #2 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Am confused, if you dont want the h2 at the bottom why not just put a page break before it?
h2 { page-break-before: always } and page-break-inside requires a container to apply to the inside of it, so if you want to use it you have to wrap the stuff you want to use it on in a div |
06-04-2021, 04:25 PM | #3 |
the rook, bossing Never.
Posts: 11,158
Karma: 85874891
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper11
|
Only Page Break Before a heading is reliable. I always use level 1 to 3 with Break Before. That also helps TOC generation.
I use styles that map to CSS that only look like headings if I don't want a page break or don't want it in the TOC. |
06-05-2021, 08:09 AM | #4 |
Addict
Posts: 283
Karma: 2228060
Join Date: Dec 2013
Location: LaVernia, Texas
Device: kindle epub readers on android
|
widows of h2 in pdf
Thanks for input. Regarding your question:"why not just put a page break before it?
h2 { page-break-before: always }" it is because the h2 segments are extremely short and look wrong if only one is on a page, but look good if bunched together as many as possible per page, but look bad with a widowed h2. The h2s show up good in the TOC. I mentioned in the questions that wrapping h2s and following Ps in a DIV certainly works and you said so:"and page-break-inside requires a container to apply to the inside of it, so if you want to use it you have to wrap the stuff you want to use it on in a div" I was trying to find an elegant solution of no widows of h2 without wrapping all h2+ps. Basically, I'm learning the ins and outs of how to solve programming css limitations. Thanks for the help. Best regards, Pop |
06-06-2021, 06:04 PM | #5 | ||
Wizard
Posts: 2,297
Karma: 12126329
Join Date: Jul 2012
Device: Kobo Forma, Nook
|
If you're aiming for EPUB2 + older ereaders, you'd use:
Code:
page-break-inside: avoid CSS3 = break-inside break-inside is a relatively recent renaming, so a lot of older devices/readers won't recognize that. Quote:
Related Side Note: There are a few bleeding edge things in CSS3 Paged Media that deal with floats (mostly for Images+Captions/Figures/Tables/Sidebars). It would allow those chunks to move to the top/bottom of next page, while the rest of the text fills the previous page. I explained some of that here: "Kindle Previewer 3.40 - 64bit, SVG text, snap-block" (Post #3+) Quote:
1. Wrap every "little section" in its own <section>: Before: Code:
<h2>Sample Heading</h2> <p>Short and sweet paragraph.</p> <p>Another short paragraph.</p> Code:
<section class="chunk"> <h2>Sample Heading</h2> <p>Short and sweet paragraph.</p> <p>Another short paragraph.</p> </section> Code:
section.chunk { page-break-inside: avoid; } And I think this is one of those cases where you can do your best to code it, then it's up to the readers themselves to be using a standards-compliant reader. |
||
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Widowed (Orphaned?) Header | SigilBear | ePub | 11 | 02-12-2017 12:12 AM |
PDF images upside down - a solution | Fingerstoo | Conversion | 4 | 12-21-2011 11:57 AM |
Possibly a solution to one of the pdf conversion problems | alansplace | Conversion | 0 | 12-20-2011 03:14 PM |
Zooming:PDF's ultimate solution? | el.astrologo | Sony Reader | 7 | 06-16-2009 10:34 AM |
Favourite PDF solution? | Vero | 4 | 04-21-2007 05:46 PM |