- From: TUSF via GitHub <sysbot+gh@w3.org>
- Date: Thu, 21 Feb 2019 21:03:58 +0000
- To: public-css-archive@w3.org
TUSF has just created a new issue for https://github.com/w3c/csswg-drafts: == [css-lists-3] Need a way to return the max value of a counter within a scope. == At the moment, one can define, increment and reset a counter, and then get the *current* value of that counter. However, it would be extremely useful to be able to get the maximum value of a counter within a certain scope. For example, to mark lists or figures with "Item 2 of 6", or in the case of [Paged Media](https://drafts.csswg.org/css-page-3/), having sets of pages each with different page counters (such as for front matter, or multiple "articles" within a single document). For this, I propose adding a `max-counter()` function, which follows the semantics of `counter()`, with the function that it outputs the *maximum* value that a counter reaches, before a counter-reset. So for example: ```CSS h1 { counter-reset: section; } h2 { counter-increment: section; } h2::after { content: counter(section) " of " max-counter(section); } ``` ```HTML <h1>Title</h1> <h2>Section</h2> <h2>Section</h2> <h2>Section</h2> <h1>Title</h1> <h2>Section</h2> <h2>Section</h2> ``` This should output something like: ``` Title Section 1 of 3 Section 2 of 3 Section 3 of 3 Title Section 1 of 2 Section 1 of 2 ``` In effect, when a counter increments, they should also increment the value of every max-counter() that precedes them, except for those before a counter-reset. This function should also eliminate the need for [the immutable `pages` counter](https://www.w3.org/TR/css-page-3/#page-based-counters). Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3667 using your GitHub account
Received on Thursday, 21 February 2019 21:04:01 UTC