W3C home > Mailing lists > Public > www-style@w3.org > March 2016

Re: [css-lists] Allow counter() to be used where numeric values are expected

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 4 Mar 2016 12:11:42 -0800
Message-ID: <CAAWBYDAa-r8hXgE0DPjPj8gxH_J+qQz4rzoThVhe8-jLYJ9vcw@mail.gmail.com>
To: Mark Crutch <mark.crutch@gmail.com>
Cc: www-style list <www-style@w3.org>
On Wed, Mar 2, 2016 at 5:32 AM, Mark Crutch <mark.crutch@gmail.com> wrote:
> I would like to put forward a suggestion to the WG to extend the scope of
> the counter() function to allow it to be used in a CSS property wherever a
> numeric value is allowed. This would only apply to counters of the "decimal"
> type.
>
> My primary reason for wanting this possibility is to do with CSS3 flexbox
> and the ordering of children therein using the "order" property. Currently
> "order" computes to 0, meaning that reordering a single child into the
> middle of a set requires all the siblings to also be given a specific
> "order" value. Without doing this, any positive value for "order" causes the
> element to jump to the end of the list of siblings as all of the others have
> an implicit value of 0. See this example in which the intention is to move
> item 1 to be between items 3 & 4 by giving it an explicit order value, but
> the outcome is that the first item is moved to the end:
>
> http://codepen.io/anon/pen/yOyvdJ
>
>
> By allowing counter() to be used in the "order" property, it would be
> possible to automatically give each child an ascending value. This would
> then meand that explicitly setting the property on one of them would move
> the child as expected. See this example for how the syntax might work in
> such a scenario:
>
> http://codepen.io/anon/pen/BKyYeg
>
>
> I could also imagine that extending the scope of counter() in this way would
> be useful in a number of other ways, particularly when combined with the
> calc() function to allow the counter value to be scaled to larger numbers.

Well, we can't really re-use counter() - the grammatical ambiguity
wouldn't be very fun, and counter() is defined to prefix/suffix (like
"1.") to the value.  It would be pretty confusing.

But a counter-value() function that resolved to the numeric value
would work.  One issue is that counters are, in at least some
browsers, *terribly* slow and hacky, so exposing counters for more
things might not go over well.

~TJ
Received on Friday, 4 March 2016 20:12:29 UTC

This archive was generated by hypermail 2.4.0 : Friday, 25 March 2022 10:09:01 UTC