Reputation: 588
Currently in java I am generating an HTML document with applicable CSS styles.
I have verified that my document is correct, however it appears that the :first
pseudo selector is not working when I use it in conjunction with a named page. as an example:
@page mainReport:first {
@top-center {
content: element(header);
vertical-align: bottom;
};
@bottom-center {
content: element(footer);
vertical-align: top;
};
}
The reason for me doing this is that I want to use the first page on a specific named page, does the CSS selector support this functionality for paged media? And if not, is there a work around for this issue, either through flying-saucer or some sort of CSS magic.
Thanks
Upvotes: 3
Views: 959
Reputation: 1307
First of all, a named page is really a particular type of page, not a specific page. You can have multiple "special" types of pages, and use each type multiple times.
Secondly, all pages, regardless of their type, share the same page numbering and page
counter. Therefore, there is really ever only a single page (namely, the very first one) in the document that matches the :first
pseudo-class.
Therefore, if the first page of the document happens to be of the special type (e.g., mainReport:first
) it will be styled accordingly. If the very first page is not of any special type, it will receive the default styling for a :first
page (or :right
page, in the absence of special styling for :first
).
There is one thing that I noticed with Flying Saucer in this regard that caused me a little bit of a headache (and I find it somewhat counterintuitive). Whereas for regular pages (i.e., non-"named" ones), it is sufficient to specify :left
and :right
styles (assuming verso and recto pages are styled differently), I also had to define a :first
style when additionally using a named page type.
For example, to have the table of contents numbered with Roman numerals I ended up with this:
@page :left
{
margin-left: 0.6in;
margin-right: 0.9in;
@left-bottom {content: counter(page);}
}
@page :right
{
margin-left: 0.9in;
margin-right: 0.6in;
@right-bottom {content: counter(page);}
}
@page toc:first
{
margin-left: 0.9in;
margin-right: 0.6in;
@right-bottom {content: counter(page, lower-roman);}
}
@page toc:right
{
margin-left: 0.9in;
margin-right: 0.6in;
@right-bottom {content: counter(page, lower-roman);}
}
@page toc:left
{
margin-left: 0.6in;
margin-right: 0.9in;
@left-bottom {content: counter(page, lower-roman);}
}
If I leave out the @page toc:first
section, Flying Saucer will apply the regular page numbers on the first page of the table of contents (but subsequent pages of the TOC will correctly have roman numeral page numbers).
Upvotes: 0