Sass and combined child selector

后端 未结 2 1433
余生分开走
余生分开走 2020-12-13 03:12

I\'ve just discovered Sass, and I\'ve been so excited about it.

In my website I implement a tree-like navigation menu, styled using the child combinator (E &g

2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 03:50

    Without the combined child selector you would probably do something similar to this:

    foo {
      bar {
        baz {
          color: red;
        }
      }
    }
    

    If you want to reproduce the same syntax with >, you could to this:

    foo {
      > bar {
        > baz {
          color: red;
        }
      }
    }
    

    This compiles to this:

    foo > bar > baz {
      color: red;
    }
    

    Or in sass:

    foo
      > bar
        > baz
          color: red
    

提交回复
热议问题