Skip to content
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

[css-lists][css-counter-styles] use counter() / counters() value inside calc() #5691

Closed
ramiy opened this issue Nov 2, 2020 · 1 comment
Closed

Comments

@ramiy
Copy link

ramiy commented Nov 2, 2020

Currently we can't use the counter() / counters() value outside on the content: ''; tag.

See this code:

ol {
  counter-reset: my-counter 4;
}

ol > li {
  counter-increment: my-counter 2;
  width: calc( 10% * counter( my-counter ) );   /* Currently this is not possible */
  background-color: red;
}

When using Numeric counters, we should be able to use the counter value inside the calc() functional notation (or any other math function - min(), max() etc).

This will allow us to style the elements based on the location of the element inside the list. Example use case is to use the counter to retrieve the element position in the list and to calculate different gradient designs.

Alternatives

There are some alternatives like the :nth-child(3), but it has no functional notation like counter() that allows you to retrieve the child element position value to be used inside calc().

Powerful Capabilities

Counters can be very powerful as you can set initial values (positive and negative values) and increase / decrement by any integer. But currently we are very limited with their use. Let's change that.

@Loirooriol
Copy link
Contributor

Duplicate of #1026

@Loirooriol Loirooriol marked this as a duplicate of #1026 Nov 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants