开发学院

您的位置:首页>教程>正文

教程正文

LESS 注释

LESS 注释

  注释使代码清晰和易于用户理解。您可以在代码中使用块样式和内联注释,但是当您编译较少的代码时,单行注释将不会出现在CSS文件中。

例子

<html>
   <head>
      <title>Less Comments</title>
      <link rel = "stylesheet" type = "text/css" href = "style.css" />
   </head>
   <body>
      <h1>Example using Comments</h1>
      <p class = "myclass">LESS enables customizable, 
      manageable and reusable style sheet for web site.</p>
      <p class = "myclass1">It allows reusing CSS code and 
      writing LESS code with same semantics.</p>
   </body>
</html>

  创建style.less文件

  style.less

/* It displays the
green color! */
.myclass {
   color: green;
}

// It displays the blue color
.myclass1 {
   color: red;
}

  使用下面命令编译less文件

lessc style.less style.css

  得到css文件

  style.css

/* It displays the
green color! */
.myclass {
   color: green;
}

.myclass1 {
   color: red;
}
输出

 让我们来执行以下步骤,看看上面的代码工作:

  •   保存上面的html代码到 comments.html 文件。

  •   在浏览器中打开该HTML文件,得到如下输出显示。

comments.jpg