目录

Less - 注释

描述 (Description)

注释使代码清晰易懂,易于理解。 您可以在代码中同时使用块样式和内联注释,但在编译LESS代码时,单行注释不会出现在CSS文件中。

例子 (Example)

以下示例演示了在LESS文件中使用注释 -

<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;
}

您可以使用以下命令将style.less文件编译为style.css -

lessc style.less style.css

现在执行上面的命令; 它将使用以下代码自动创建style.css文件 -

style.css

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

输出 (Output)

请按照以下步骤查看上述代码的工作原理 -

  • 将上述html代码保存在comments.html文件中。

  • 在浏览器中打开此HTML文件,将显示以下输出。

少评论
<上一篇.Less - Scope
↑回到顶部↑
WIKI教程 @2018