View Single Post
Old 09-03-2014, 01:56 AM   #20
Ripplinger
350 Hoarder
Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.Ripplinger ought to be getting tired of karma fortunes by now.
 
Ripplinger's Avatar
 
Posts: 3,574
Karma: 8281267
Join Date: Dec 2010
Location: Midwest USA
Device: Sony PRS-350, Kobo Glo & Glo HD, PW2
Quote:
Originally Posted by AlexBell View Post
Here is the CSS I use for poetry - each verse goes in its own div

div.verse {
margin: 0.5em 0 0.5em 1em;
padding: 0;
page-break-inside:avoid;
} /* Sets top margin and and prevents verses breaking */
div.verse p { text-indent: -2em;
margin-left: 2em;
text-align: left;
margin-bottom: 0;
padding: 0; } /* Aligns text left, indents lines after break */
div.verse+p { text-indent:0; }

I know it works because I sometimes have to disable the 'page-break-inside:avoid' if verses are too long.

I hope this helps, and if there is any way of doing it better please let me know.
I was thinking about using a div class too earlier but then forgot about it. But I just tried a simplified version of this now and it works perfectly on both my Sony 350s and Kobo Glos.

In the stylesheet I added:

div.sectionstart {
page-break-inside:avoid;
}

And around the section number and first paragraph only I used:

<div class="sectionstart"> (with </div> right after the first paragraph).

And it avoided the section numbers from ever dangling by their lonesome on a preceding page. (And now a few of us know how the "page-break-inside" is meant to work. )

I was afraid of what might happen if someone enlarged the text enough so the first paragraph wouldn't fit on one page with the section number, and that wasn't a problem either. The paragraph just continued onto the following page like I would hope.

So I'm pretty happy with this solution. If there's enough room on a page with the previous section, it will continue on that same page, so there's a minimum of blank space between the sections like I wanted without resorting to 100 html pages within the epub.

Thanks all for the help with this.

Edit: But now this makes me wonder why does using "avoid" work with page-break-inside, but not with page-break-before or page-break-after? Just curiosity at this point, like I said, I'm happy with this result. Possibly the difference is that it works when used with <div>?

Last edited by Ripplinger; 09-03-2014 at 02:11 AM.
Ripplinger is offline   Reply With Quote