5. 注释 / / 与 // (Comments: / / and //)
5. 注释 // 与 // (Comments: // and //)
Sass 支持标准的 CSS 多行注释 / /,以及单行注释 //,前者会被完整输出到编译后的 CSS 文件中,而后者则不会,例如:
1. /* This comment is2. * several lines long.3. * since it uses the CSS comment syntax,4. * it will appear in the CSS output. */5. body { color: black; }7. // These comments are only one line long each.8. // They won't appear in the CSS output,9. // since they use the single-line comment syntax.10. a { color: green; }
编译为
1. /* This comment is2. * several lines long.3. * since it uses the CSS comment syntax,4. * it will appear in the CSS output. */5. body {6. color: black; }8. a {9. color: green; }
将 ! 作为多行注释的第一个字符表示在压缩输出模式下保留这条注释并输出到 CSS 文件中,通常用于添加版权信息。
插值语句 (interpolation) 也可写进多行注释中输出变量值:
1. $version: "1.2.3";2. /* This CSS is generated by My Snazzy Framework version #{$version}. */
编译为
1. /* This CSS is generated by My Snazzy Framework version 1.2.3. */
