Re: [csswg-drafts] [css-pseudo] Add a ::contents pseudo-element

> Where would you see benefits of having `::contents` over `@text`?
> > 
> > I may want to take some element out-of-flow like in absolutely positioning, but still reserve some space where it would be with static positioning. Easy:
> >
> > ```css
> > #target { width: 100px; height: 100px; }
> > #target::contents { display: block; position: absolute }
> > ``` 

And where is that a beneficial (more flexible/reusable / easier to grasp / shorter) syntax over `@text`?:
```css
#target { width: 100px; height: 100px; }
#target > @text { display: block; position: absolute }
```

> > I may want to generate ::after outside the element, e.g. the element is a flex item and I want ::after to participate in the same flex formatting context. Easy:
> >
> > ```css
> > #target { display: contents }
> > #target::after { content: "" }
> > #target::contents { display: block }
> > ```

```css
#target { display: flex }
#target > @text { color: red; /* red flex item(s) */ }
#target::after { color: green; content: "green flex item after" }
```
`@text` does a similar thing?

What would happen in case of `::contents` with sub-elems of #target that become flex items by default? Would there exist multiple `::contents` nodes in between those?

> > I may want the contents of an element to be wrapped in a stacking context separated from ::after, e.g. because I want to ensure ::after will overlap the contents even if there is some descendant with z-index: 99999999999999. Easy:

Note sure I got the use case.

Don't get me wrong, I rather see ``::contents`` live than nothing to happen, but I want to make sure that we can't have a more general purpose solution than that, that also follows the cascade and has a clear place in specificity order. Also `@text` may be a bad selector name for those anonymous text nodes. It is just a name for now.


-- 
GitHub Notification of comment by inoas
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2406#issuecomment-371773830 using your GitHub account

Received on Friday, 9 March 2018 10:24:40 UTC