-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[css3-page] CSS counter for position fixed elements on paged media #1879
Comments
For the record: the example is still present on the current revision. The rev'd URL was used on Chromium issue to make sure the reference doesn't break in the future. (Thanks for filing BTW) |
The Firefox behavior is so buggy. If you create a static element after I think counter values should lie in the element tree, so Also see #1026, a proposal to read counters in arbitrary properties. I don't think this can be possible if counter values belong to fragments. |
Interesting, so the behavior of Firefox is actually undesired? How do I move this forward? Should I just submit a pull request to the spec draft? |
Any updates? |
Counter increment for fixed elements when printing is useful in creating page numbers of page's footer. So
is expected. |
Any updates/plans for fixing this issue? |
Per the current spec https://drafts.csswg.org/css-lists/#creating-counters counter values should percolate thru the element tree, same as other styles; it just has a funky "inherit from preceding element in the document" instead of the normal inheritance from its parent element. That said, I know that Blink, at least, actually inherits thru the box tree and attempts to emulate inheriting thru the element tree (which results in some bugs, and also some bad perf stuff). To get a page counter, the intention is that you do a counter-reset/increment in @page, then counter() will pick up the correct value based on what page it ends up on. (And presumably will change values in fixpos appearing on multiple pages? This isn't well-defined.) |
I can comment on the Firefox behavior, and I can confirm that it's just an accident of how fixed-pos replication during printing is implemented. I'd consider it a bug. |
Does not work, even in firefox. Was that what you were talking about? |
(I'm deleting useless "ping" comments. Please do not ping without new information; we'll get to the issue when we get to it, otherwise.) |
@page {
counter-increment: page;
@bottom-center {
content: counter(page);
}
} This works in all paged-media focused engines. If it's not working then that's an issue with the implementation, not the spec. It's already been pointed out that counter values must be derived from the element tree, I just wanted to add that this approach underlies the |
I made an edit on MDN to explain the snippet. @page margin boxes are not implemented in any major browser engine yet, neither did |
Getting back to OP's post, I just solved this little quirk while working on another project. Chrome refused to increment the counter until I called the counter reset. Once I did that, whole thing started working.
|
@BattlemageBob, for me, firefox shows the total page counting at first page and nothing else at others. At chrome, always 1 at every page. body
{
counter-reset: page;
}
footer
{
counter-increment: page;
position: fixed;
}
footer::before
{
content: counter(page);
} |
@page {
counter-increment: page;
}
body {
counter-reset: page;
}
.pagination {
position: fixed;
top: 0;
}
.pagination::before {
content: counter(page);
} Firefox: prints zero at first page, nothing on the others |
is this one still ongoing? I can confirm what @darakeon expirienced 1,5 years ago. Cheers. |
This still seems to be a problem. faceless2's suggestion may have worked but no longer does as you apparently can't add content to a @page section. So far every suggestion and variation doesn't not work, My thought is the element won't increment because even though a fixed element will repeat on printed pages it only sees it as a single element so won't increment the counter like it does in a list element. ID or class seems irrelevant too. Getting total number of pages doesn't work either |
Behavior: * (Page) counters in fixed-position elements: Only consider initial position for `counter-increment`/`counter-set` (NEW), but current counter values are used for the `counter` functions in `content` * Page-based counters can be manipulated with `counter-increment`/ `counter-set` within the page (should this be kept, makes implementation more complicated esp. with `counter-set`) TODO: * Fix root counter handling (currently body counters and root counters are handled on the root, should be separate) * Take `counter-set` on regular element into account for page counters (would make it possible to reset the `page` counter via `counter-set: page 1;` on any element) * Handling counters during frame split (copy)? * Add tests for counters with page break, esp. involving shrink-to-fit width https://www.w3.org/TR/css-page-3/#page-based-counters For background on how page counters should work: * Kozea/WeasyPrint#631 (comment) * Kozea/WeasyPrint#289 (comment) * w3c/csswg-drafts#1879
(From Blink issue 774830)
A retired MDN example showed page numbers using
The behavior differs across browsers:
Firefox:
Chrome, Edge:
Safari:
Which behavior is correct? Should the counter-increment occur each time the element is rendered?
The text was updated successfully, but these errors were encountered: