html - How can I suggest horizontal rules as good page-breaking points? -


i'm trying optimize pages via css printing browser. problem i'm having setting page breaks properly. have preventing page-breaks in middle of images , blocks of text shouldn't separated how want. however, problem i'm having there's horizontal rule separating new section , just title of next section (and potentially description of section), rest of actual section displayed on next page. confusing , poor formatting, if title of section close bottom of page, you'd throw in page break before bump whole thing next page , not worry tiny amount of space on previous page you're sacrificing.

page break dilemma

the html here simplistic. it's not wrapped in million things, horizontal rule, header, paragraph description, content of section. tried wrap header , description in division , make can't page-break inside or after, so:

<a id="section_1"></a> <div class="no-page-break">     <h2>section 1</h2>     <p>section 1 description</p> </div> <div>     <!-- content section --> </div> <hr /> <a id="section_2"></a> <div class="no-page-break">     <h2>section 2</h2>     <p>section 2 description</p> </div> <div>     <!-- content section --> </div> <!-- , on --> 
.no-page-break { page-break-after: avoid; page-break-inside: avoid } 

i hoping see entire block un-breakable , bump whole thing down next page, didn't anything. maybe i've been staring @ problem long. know how prevent each section of page breaking in manner?

note: don't want always break before each section, potentially waste lot of page space if there's little bit leftover previous one.

bonus: if knows how you'd able hide horizontal rule if broke @ point, that'd helpful too. that's minor annoyance i'm not worried about.

the way can think of move horizontal rule bottom of last section , before want page break. wrap next section in node , add no-page-break that. there many factors when printing browser cannot detect if can cleverly group things lot.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -