注释

Sass注释的工作方式在SCSS和缩进语法之间大不相同。两种语法都支持两种类型的注释:(/* */通常)将使用定义的注释编译为CSS,//而不使用注释定义的注释。

SCSS永久在  SCSS

SCSS中的注释的工作方式类似于JavaScript等其他语言的注释。单行注释以开头//,直到行尾。CSS不会发出任何注释。就Sass而言,它们也可能不存在。它们也称为静默注释,因为它们不产生任何  CSS。

多行注释开始/*,并在下次结束*/。如果在允许语句的某处写了多行注释,那么它将被编译为CSS注释。与无声评论相比,它们也被称为大声评论。编译为CSS的多行注释可能包含内插,将在编译注释之前对其进行评估。

默认情况下,多行注释以压缩模式从已编译的CSS中剥离。但是,如果注释以开头,则它将始终包含在CSS  输出中。/*!

SCSS  语法

// This comment won't be included in the CSS.

/* But this comment will, except in compressed mode. */

/* It can also contain interpolation:
 * 1 + 1 = #{1 + 1} */

/*! This comment will be included even in compressed mode. */

p /* Multi-line comments can be written anywhere
   * whitespace is allowed. */ .sans {
  font: Helvetica, // So can single-line commments.
        sans-serif;
}

CSS  输出

/* But this comment will, except in compressed mode. */
/* It can also contain interpolation:
 * 1 + 1 = 2 */
/*! This comment will be included even in compressed mode. */
p .sans {
  font: Helvetica, sans-serif;
}







在Sass永久链接在Sass

缩进语法中的注释的工作方式略有不同:它们与其他语法一样,都是基于缩进的。与SCSS一样,用编写的无声注释//也不会作为CSS发出,但与SCSS不同,在开口下方缩进的所有内容//也会被注释掉。

从缩进开始的缩进语法注释/*以缩进方式工作,只是将它们编译为CSS。因为注释的扩展基于缩进,所以关闭*/是可选的。也像SCSS一样,  /*注释可以包含插值,并且可以从其开始/*!以避免在压缩模式下被剥离。

注释也可以缩进语法在表达式内使用。在这种情况下,它们具有与SCSS中完全相同的语法 

Sass语法

// This comment won't be included in the CSS.
   This is also commented out.

/* But this comment will, except in compressed mode.

/* It can also contain interpolation:
   1 + 1 = #{1 + 1}

/*! This comment will be included even in compressed mode.

p .sans
  font: Helvetica, /* Inline comments must be closed. */ sans-serif

CSS  输出

/* But this comment will, except in compressed mode. */
/* It can also contain interpolation:
 * 1 + 1 = 2 */
/*! This comment will be included even in compressed mode. */
p .sans {
  font: Helvetica, sans-serif;
}

文档注释永久链接文档注释

使用Sass编写样式库时,可以使用注释来记录 库提供的mixins函数变量占位符选择器,以及库本身。这些注释由SassDoc工具读取,该工具使用它们生成漂亮的文档。请查看Susy Grid Engine的文档,以查看实际运行情况!

文档注释是无声注释,///在要记录的内容的正上方带有三个斜杠()。SassDoc将注释中的文本解析为Markdown,并支持许多有用的注释以对其进行详细描述。

SCSS  语法

/// Computes an exponent.
///
/// @param {number} $base
///   The number to multiply by itself.
/// @param {integer (unitless)} $exponent
///   The number of `$base`s to multiply together.
/// @return {number} `$base` to the power of `$exponent`.
@function pow($base, $exponent) {
  $result: 1;
  @for $_ from 1 through $exponent {
    $result: $result * $base;
  }
  @return $result;
}

Sass语法

/// Computes an exponent.
///
/// @param {number} $base
///   The number to multiply by itself.
/// @param {integer (unitless)} $exponent
///   The number of `$base`s to multiply together.
/// @return {number} `$base` to the power of `$exponent`.
@function pow($base, $exponent)
  $result: 1
  @for $_ from 1 through $exponent
    $result: $result * $base

  @return $result