What does '&.' in '&.sub-title' indicates in scss?

后端 未结 1 1652
Happy的楠姐
Happy的楠姐 2020-11-29 20:49

I am a newbie to CSS and SCSS.

In the following code,

.title {
    width: 718px;
    &.sub-title {
      width: 938px;
   }
}

W

1条回答
  •  -上瘾入骨i
    2020-11-29 21:45

    The & concatenates the parent class, resulting in .title.sub-title (rather than .title .sub-title if the & is omitted).

    The result is that with the & it matches an element with both title and sub-title classes:

    whilst without the & it would match a descendent with class sub-title of an element with class title:

    ...
    ...

    0 讨论(0)
提交回复
热议问题