“一个”是什么意思&&引用;CSS中的伪元素之前是什么意思?

“一个”是什么意思&&引用;CSS中的伪元素之前是什么意思?,css,twitter-bootstrap,Css,Twitter Bootstrap,在下面的CSS中,符号(&)是什么意思 .clearfix { *zoom: 1; &:before, &:after { display: table; content: ""; } &:after { clear: both; } } 那是,不是CSS 此语法允许嵌套选择器修饰符 .clearfix { &:before { content: ''; } } 将编译为: .clearfix:

在下面的CSS中,符号(&)是什么意思

.clearfix {
  *zoom: 1;
  &:before,
  &:after {
    display: table;
    content: "";
  }
  &:after {
    clear: both;
  }
}
那是,不是CSS

此语法允许嵌套选择器修饰符

.clearfix { 
  &:before {
    content: '';
  }
}
将编译为:

.clearfix:before {
  content: '';
}
使用
&
,嵌套选择器编译为
.clearfix:before


没有它,它们编译成
.clearfix:before
嵌套的
&
选择SASS和LESS中的父元素。它不仅适用于伪元素,还可以用于任何类型的选择器

e、 g

相当于:

h1.class {

}

以下是一个SCSS/LESS示例:

a {
   text-decoration: underline; 
   @include padding(15px);
   display: inline-block;

     & img  {
                padding-left: 7px;
               margin-top: -4px;
             }
 }
以及CSS中的等效项:

a {
  text-decoration: underline; 
  @include padding(15px);
  display: inline-block;
}

a img  {
     padding-left: 7px;
     margin-top: -4px;
   }

在Sass和Less中,
&
是对父选择器的引用。@KatieK:Bootstrap是用Less而不是Sass编写的
a {
  text-decoration: underline; 
  @include padding(15px);
  display: inline-block;
}

a img  {
     padding-left: 7px;
     margin-top: -4px;
   }