csstools / postcss-nesting

Nest style rules inside each other

Home Page:https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question

equinusocio opened this issue · comments

Hi @jonathantneal, i can't figure out if this expresion & + & works with this plugin. Take this example:

  .NagivationItem {
    color: var(--foregroundColor, #000);
    text-decoration: none;

    /* & + .Class works as expected but not this ...
       It should be .NagivationItem + .NagivationItem {}, got:
        .NagivationItem { & + & {..} }   
    */
    & + & {
      margin-left: 90px; 
    }
  }

@jonathantneal maybe is not in the house....Have you ever tried with @nest directive:
@nest & + & {...}?

I’m sorry for the delayed response. The nesting defined by the CSSWG is not the same as the nesting in Sass.

In CSS, the & selector represents an Element. It does not represent a selector string, as it did in Sass.

Writing & + & is like writing “match an Element that comes after itself”, which is not possible.