0

I have created a simple print style sheet and what is happening is that when the text reaches the end of the first page, instead of flowing to the next page, like in word, the text seems to be splitting and half is on the first page and the next half is on the second page. Is there a way with css to correct this. I have done a grab to illustrate the problem, Thanks

css

body {margin:0; padding:0; line-height: 1.4em; word-spacing:1px; letter-spacing:0.2px; font: 13px Arial, Helvetica,"Lucida Grande", serif; color: #ff0000; }
table { border: none; }
.noPrint { display:none; }

enter image description here

asked Sep 20, 2011 at 14:21

1 Answer 1

2

You can use the following to force a page break before a specific element:

#yourElementID {page-break-before:always;}

Edit:

I had assumed there was some other elements above your table, but looking again, you may just be printing reams and reams of table data? I am not sure how to solve this if that is the case.

answered Sep 20, 2011 at 14:25
Sign up to request clarification or add additional context in comments.

4 Comments

diagonalbatman, your assumption is correct. The results that go into the printed page are dynamic so are as such out of my control. However, is there not a way to limit the amount of data then force a page break? Thanks
I suppose this could go down to how you present your output. For example, you could calculate how many rows can fit into a page, then use an nth child selector reference.sitepoint.com/css/pseudoclass-nthchild on every X rows of data in your table ans stick the page break code in there? I dont know how well this will work however (if at all) just thinking out loud
thanks for input. suppose another way to go would be to do an if statement in php and for every 15 records perhaps do something along the lines of: if($i > 15) { echo '<br style="page-break-before:always;">'; }
You could do - but not sure how a <BR> inside tabluar elements is rendered by the browser - it may cause more issues.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.