在 Sass 中注釋有兩種方式:
1、類似 CSS 的注釋方式,使用 ”/* ”開頭,結屬使用 ”*/ ”
2、類似 JavaScript 的注釋方式,使用“//”
Sass 支持標準的CSS多行注釋以/* */以及單行注釋 //。
兩者區別:前者會在編譯出來的 CSS 顯示,后者在編譯出來的 CSS 中不會顯示
在盡可能的情況下,多行注釋會被保留在輸出的CSS中,而單行注釋會被刪除。 例如:
CSS Code復制內容到剪貼板
/* This comment is
* several lines long.
* since it uses the CSS comment syntax,
* it will appear in the CSS output. */
body { color: black; }
// These comments are only one line long each.
// They won’t appear in the CSS output,
// since they use the single-line comment syntax.
a { color: green; }
編譯為:
CSS Code復制內容到剪貼板
/* This comment is
* several lines long.
* since it uses the CSS comment syntax,
* it will appear in the CSS output. */
body {
color: black; }
a {
color: green; }
如果多行注釋的第一個字母是 !,那么注釋總是會被保留到輸出的CSS中,即使在壓縮輸出模式下。這可用于在你生成的CSS中添加版權聲明。
使用插值語句 (interpolation) ,可以將變量值輸出到多行注釋中,例如:
CSS Code復制內容到剪貼板
$version: "1.2.3";
/* This CSS is generated by My Snazzy Framework version #{$version}. */
編譯為:
CSS Code復制內容到剪貼板
/* This CSS is generated by My Snazzy Framework version 1.2.3. */
新聞熱點
疑難解答