描述
注释使代码清晰易懂,易于理解.您可以在代码中同时使用块样式和内联注释,但是当您编译LESS代码时,单行注释将不会出现在CSS文件中.
示例
以下示例演示了在LESS文件中使用注释 :
Less Comments Example using Comments
LESS enables customizable, manageable and reusable style sheet for web site.
It allows reusing CSS code and writing LESS code with same semantics.
现在创建 style.less 文件.
style.less
/* It displays thegreen 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 thegreen color! */.myclass { color: green;}.myclass1 { color: red;}
输出
按照以下步骤查看上述代码的工作原理;
将上述html代码保存在 comments.html 文件中.
在浏览器中打开此HTML文件,将显示以下输出.