欢迎加入QQ讨论群258996829
麦子学院 头像
苹果6袋
6
麦子学院

学习Sass之注释

发布时间:2016-07-23 22:14  回复:0  查看:2452   最后回复:2016-07-23 22:14  

在本章中,让我们学习SASS 的注释。注释是放置在源代码中不可执行的语句。注释使源代码更易于理解。SASS支持两种类型的注释。

 

 

 

多行注释 - 这些使用 /**/ 写入。多行注释都保留在CSS输出。

 

单行注释 - 这些是使用//跟着注释。单行注释不会保留在CSS输出。

 

实例

下面的例子演示了SCSS 文件中使用注释:

<html>

<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>SASS注释 - www.yiibai.com</title>

   <link rel="stylesheet" type="text/css" href="style.css"/>

</head>

<body>

  <h1>Welcome to YiiBai</h1>

  <a href="http://www.yiibai.com/">Yiibai Yiibai</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之注释

 

 

 

原文来自:易百

您还未登录,请先登录

热门帖子

最新帖子