PDA

View Full Version : [solved] <p id="page_break"> css #page-break-after:always not working in Firefox.


Dolphin123
06-10-2005, 02:50 PM
Ok I have an image after which I want to force a pagebreak.

So wrote:

<img src ....> <p id="page_break"></p>

then in the print stylesheet wrote:

#page_break { page-break-after: always }

which works fine in IE, but not in Firefox.
Couldn't find any clear posts on this particular problem.

Thanx for any help.

sesshyzkidz
06-10-2005, 04:02 PM
I haven't really messed with this, but have you tried 'page-break-before'? If you are wanting to cut the page right after the image, that seems to be the most logical idea. This also would allow you to continue with your content (unless it's a page full of images) without interruption.

Sorry if this doesn't help.

Dolphin123
06-10-2005, 06:55 PM
Yeah none of the page-break commands seem to work in Firefox at this point. My guess it has something to do with using the paragraph tag, although it should'nt.

Don't know am going to take a look at it tonight. Thanx for your time anyway though.

mark87
06-10-2005, 08:12 PM
Why not add it to the image (and I haven't used the page break declaration before so I could be speaking out of my .. lol) - Something like -

<img class="page_break" src="">

img.page_break { page-break-after: always }

?

The W3 states -

Note: You can not use this property on absolutely positioned elements.

Note: Use the page-breaking properties as few times as possible and avoid page-breaking properties inside tables, floating elements, and block elements with borders.

Dolphin123
06-10-2005, 09:41 PM
Hej Mark,

Allright did manage to get it to work (sorta*) using the following code: :cool:
*In the website I am building this breaks the printpage as soon as the printpage is full in the Netscape group, whereas in IE it breaks exactly after the image. Good enough. ;)

Using a stylesheet to call up the same function rendered it absolutely useless in the Netscape group for the website I was building , so had to place the code in the document.

You need to use the CSS "page-break-before" or "page-break-after" properties. Here's a working example:

<html>
<head>
<style type='text/css'>
@media print
{
.pagestart
{
page-break-before: always;
}
}
</style>
</head>
<body>
<p>This is on page 1.</p>
<p class='pagestart'>This is on page 2.</p>
</body>
</html>

except changed the <p class> to a <div class>

so the finished code looks like:

<html>
<head>
<style type='text/css'>
@media print
{
.pagestart
{
page-break-after: always;
}
}
</style>
</head>
<body>
<p>This is on page 1.</p>
<div class='pagestart'><img src.....>(or other content)</div>
</body>
</html>

-Normally I quote the author or source of the code. Unfortunately I don't remember either. My apologies for this.


Which solves it. It worked seemlessly in IE, the conclusion I came up with for the Netscape group was the 'fit to page' function, which might mess up the page-break. However I have no basis to prove this. Paste the sample code in a new page and it works fine in the Netscape group, performing the page-break cleanly.

You will have to play around to see which works better in a specific case 'before' or 'after' and where to place the 'class' in relation to the content.

and avoid page-breaking properties inside tables, floating elements, and block elements with borders.

Allright, that could also be causing the problem as the content is in a database table.

All in all getting the pages to print properly in all browsers, took about 30 hours. (and I believe I am a bit balder now, and it is a good thing the computer is a considerable distance from the window. LOL) That's a lot a time to spent on getting something print ready... I do hope they start designing browsers more for print-layout. The 'fit to page' property might be a step in the right direction, and I am sure that IE wil probably add this in their browser as well if it proves succesful.

It would be nice though if there were some design faq's (maybe there are already) with specifications for table, div, content sizes in direct relation to different print layouts.

Alternatively some piece of code, possibly within the browsers, that would (automatically) create a page-break after a certain amount of textlines or amount of pixels, similar to a wordprocessor. Where the designer would keep the option at how many lines of text or pixels this would happen at. So in essence being able to choose paper sizes, even automatically such as letter, a4, a5, etc.

Something like:
css stylesheet: printsize { A4; cutoff: 50 li; }
li= lines of text

I hope this post helps some people that might be experiencing the same problem.

_Aerospace_Eng_
06-10-2005, 11:27 PM
Some browsers don't support the import feature in CSS. The latest ones do, but browsers like NS4 won't support it then again I don't code for NS4 or much less IE5 for mac.

Dolphin123
06-10-2005, 11:41 PM
Yep. Thanx Aero

Found this today, which was of some help:

http://nanobox.chipx86.com/browser_support.php

which shows a table with web browser standards support. Also it has direct links to W3C for the css commands.

This was just one of those buggy problems, that didn't seem to make sense, because everything said it should work, but didn't. Thankfully the problem was solved and the site is finished. (before the weekend ;) )