-
Notifications
You must be signed in to change notification settings - Fork 718
[css-values-5] Introduce sibling-index()
and sibling-count()
(#4559)
#9134
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -945,8 +945,51 @@ Generating/Caching Random Values: the <<random-caching-options>> value</h4> | |||||||||||
</pre> | ||||||||||||
</div> | ||||||||||||
|
||||||||||||
<!-- | ||||||||||||
████████ ██ ████████ ██ ██ ████████ ██ ██ ████████ ██████ ███████ ██ ██ ██ ██ ████████ ████ ██ ██ ██████ | ||||||||||||
██ ██ ██ ███ ███ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ███ ██ ██ ██ | ||||||||||||
██ ██ ██ ████ ████ ██ ████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ████ ██ ██ | ||||||||||||
██████ ██ ██████ ██ ███ ██ ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ████ | ||||||||||||
██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██ ██ ████ ██ ██ | ||||||||||||
██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ███ ██ ██ ██ ███ ██ ██ | ||||||||||||
████████ ████████ ████████ ██ ██ ████████ ██ ██ ██ ██████ ███████ ███████ ██ ██ ██ ████ ██ ██ ██████ | ||||||||||||
--> | ||||||||||||
|
||||||||||||
<h2 id=element-counting> | ||||||||||||
Counting Elements</h2> | ||||||||||||
|
||||||||||||
Authors often want to apply element specific styles | ||||||||||||
based on the position of the element within the tree. | ||||||||||||
|
||||||||||||
The ''sibling-index()'' and ''sibling-count()'' functions | ||||||||||||
(the <dfn export for=CSS>element counting functions</dfn>) | ||||||||||||
allow authors to take these factors into account in ''calc()'' expressions. | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Just a light rewrite to avoid implying that these are only valid in calc().) |
||||||||||||
|
||||||||||||
With these, authors can create things like staggered animation delays | ||||||||||||
or easily position elements on a circle. | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
These functions are substituted with whatever value they resolve to | ||||||||||||
at [=computed value=] time. | ||||||||||||
|
||||||||||||
<h3 id=sibling-index> | ||||||||||||
Getting the position of an element within its siblings: the ''sibling-index()'' function</h3> | ||||||||||||
|
||||||||||||
The <dfn>sibling-index()</dfn> function resolves to the position | ||||||||||||
of an element within its group of <a>inclusive siblings</a> | ||||||||||||
Comment on lines
+977
to
+978
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
in the <a>flat tree</a>. | ||||||||||||
|
||||||||||||
Similar to '':nth-child()'', the list of elements is <b>1-indexed</b>; | ||||||||||||
that is, the first child of an element has index 1. | ||||||||||||
|
||||||||||||
<h3 id=sibling-count> | ||||||||||||
Getting the number of siblings an element is part of: the ''sibling-count()'' function</h3> | ||||||||||||
|
||||||||||||
The <dfn>sibling-count()</dfn> function resolves to the total number of | ||||||||||||
<a>inclusive siblings</a> in the <a>flat tree</a> an element is part of. | ||||||||||||
Comment on lines
+987
to
+988
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
||||||||||||
That is, it resolves to | ||||||||||||
the total number of direct children the element’s parent element contains, | ||||||||||||
<a lt="flat tree">after flattening</a>. | ||||||||||||
|
||||||||||||
<!-- | ||||||||||||
████████ ████████ ██████ | ||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Keep these headings as short as possible; if they wrap (as they definitely will on many screens, given how long these lines are) they become unreadable. I'd probably just do "COUNT" or maybe two lines having "INDEX" and "COUNT".