PDA

View Full Version : Page Breaks w/ absolute positioning


japangreg
07-31-2003, 08:14 PM
Hey, everyone.

I'm trying to make a print CSS for my web site; so far I have one that positions all of the elements I want to print in the correct place and eliminates all those I don't want to print.

However, I am using position: absolute to move the content of my site to the left and top to align it with the page; the content is a series of paragraphs and when I print it out, one of the lines gets chopped between two pages.

As I understand it, page-break-inside attributes don't work for absolutely poisitoned elements, do they? If not, is there another way to get the same effect?

Thanks in advance!
japangreg

Eskimo
07-31-2003, 08:36 PM
@media print (http://www.w3.org/TR/CSS2/page.html#page-break-props) actually does what you need...but it doesn't work in IE and I'm not sure if it does in other agents.

japangreg
07-31-2003, 09:17 PM
Hey, Eskimo.

Yeah, that's what I'm using. I have two style sheets, one for screen and one for print.

The problem is coming up because the way the site is displayed on screen there's a large gutter of dead white space that is used for our sub navigation. When you print out the page, the gutter forces the text so far to the right that the text gets chopped off by the printer.

What I did in the print sheet is position the text absolutely to the top left, so that it prints out cleanly. It works, except that I can't get it to recognize page breaks correctly.

Any other suggestions?

Eskimo
07-31-2003, 09:25 PM
I'm sorry, I actually read your post, but must have left my brains somewhere on the back 40.....errrp..

Do you have a link to your page?

japangreg
07-31-2003, 09:54 PM
No; I'm working on it locally. The person who is in charge of the web site is an idiot and will give me hell if I post something for testing purposes (she's the one who okayed the gutter in the first place)

If you make an absolutely poisitioned DIV with enough text in it to run to another page on print out, you should get the same results.

japangreg
08-01-2003, 06:00 PM
Sorry, just bumping this a bit; does anyone know if this is a lost cause or if there is a work around? Should I try to adjust the content's position using negative margins?

MotherNatrsSon
08-01-2003, 06:25 PM
In your print css couldn't you just resize the div so it fits on the page by id? Just a thought. Do not "know" if it can be done, but it might work if you lose the gutter in the print version.

MNS

Ben@WEBProp
08-01-2003, 06:26 PM
Save a backup copy of your page that you are altering and then go ahead and try the negative margins idea. If it doesn't work, revert to the backup and try something else.

-Ben

Roy Sinclair
08-01-2003, 06:54 PM
You should be able to get rid of all that space entirely using a @media = print style sheet. All it should take is giving the elements you don't want to print "display: none;" (make sure you aren't using the visibility style).

Don't use "position: absolute" to move the content around, adjust the margin and padding properties instead. I think it's the position: absolute for the body content which is causing you to loose the page breaks.