View Single Post
Old 10-12-2014, 12:01 AM   #1
Psymon
Chief Bohemian Misfit
Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.Psymon ought to be getting tired of karma fortunes by now.
 
Psymon's Avatar
 
Posts: 571
Karma: 462964
Join Date: May 2013
Device: iPad, ADE
Keeping text together (block vs. page-break-inside:avoid)

Hey folks...

In working on this current e-book, in various places I wanted to keep certain text together -- for example, the first couple and last couple of lines in a poem; or in my table of contents where I have a main chapter heading listed, as well as subheadings within that chapter (and I wanted to keep the main chapter heading together with at least the first subheading); or with a linked item in my ToC which has short description below it that I'd like to keep together; and a few other places like that.

The way I was doing it up until this evening was by wrapping whatever text I wanted to keep together in a <div> with this style...

Code:
.block {
    display: inline-block;
	width: 100%;
}
...although the whole time I was doing it that way, I found that adding that in, in-between paragraphs, tended to screw around with the top/bottom margins between paragraphs. After a lot of fiddling with my CSS, I managed to overcome those top/bottom margin issues...

...and then just this evening I discovered a totally different option that I could have used -- "page-break-inside:avoid" -- which I also just add in with a <div> around whatever few lines I want to keep together, and which doesn't seem to impose any screwiness to my paragraph margins.

Any thoughts on what the best way is for keeping text together like that -- generally just a couple of short lines (as separate paragraphs) that you don't want to get split up over two pages?

I thought that block way was "the" way to do it, but after reading various things here about "page-break-inside:avoid", now I'm not so sure.
Psymon is offline   Reply With Quote