Sass 我是否需要使用&&引用;是否使用此SCSS代码?不管有没有它,我都能得到相同的输出

Sass 我是否需要使用&&引用;是否使用此SCSS代码?不管有没有它,我都能得到相同的输出,sass,Sass,第一个: .social { margin: 0; padding: 0; list-style: none; display: flex; > li > a { position: relative; display: block; width: 26px; height: 26px; background: #fff; border-radius: .1875em; } > li + li {

第一个:

.social {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;

  > li > a {
    position: relative;
    display: block;
    width: 26px;
    height: 26px;
    background: #fff;
    border-radius: .1875em;
  }

  > li + li {
    margin-left: .8em;
  }
}
第二条:

.social {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;

  & > li > a {
    position: relative;
    display: block;
    width: 26px;
    height: 26px;
    background: #fff;
    border-radius: .1875em;
  }

  & > li + li {
    margin-left: .8em;
  }
}
两者之间的唯一区别是,第二个使用的是与&。
&
获取父名,但是,即使我使用第一个代码段中的
>li>a
,输出也将包括父名
.social>li>a

第一个可以吗?只是为了在没有符号的情况下使用它?

准确。在您的示例中,两个结果将是相同的。这两个示例都为子类生成了一个类构造,子类之间用空格表示

当以下内容之间没有空格时,需要使用符号
为伪类编写css:

 // sass
.class {

   color: green;

   &:hover {
      color: red;
   }
}

// result will be without space....
.class {
   color: green;
}

.class:hover {
 color: red;
}