SCSS, simplify/factorize ::after selector

时间:2016-10-20 12:56:19

标签: sass

Let's illustrate with an example.

I want the element ::after sort class to be red, and blue if sort order class is descending, I use the following scss.

.sort {
  ::after{
    color: red;
  }
  &.desc::after {
    color: blue;
   }
}

Is there a way to simplify the two ::after ?

.sort::after {
  color: red;
  &.desc {
    color: blue;
  }
}

Is not ok as will be compiled to .sort::after.desc.

What I would like to obtain is .sort.desc::after.

Is there a way to simplify my example and remove the duplicated ::after ?

1 个答案:

答案 0 :(得分:1)

不幸的是,这是不可能的,可能不会成功。请参阅this answer中相关GitHub问题的链接。