
- 語言特性
- Less - 巢狀規則
- Less - 巢狀指令和冒泡
- Less - 運算子
- Less - 轉義
- Less - 函式
- Less - 名稱空間和訪問器
- Less - 作用域
- Less - 註釋
- Less - 匯入
- Less - 變數
- Less - 擴充套件
- Less - 混合宏
- Less - 引數化混合宏
- Less - 混合宏作為函式
- Less - 向混合宏傳遞規則集
- Less - 匯入指令
- Less - 匯入選項
- Less - 混合宏保護
- Less - CSS 保護
- Less - 迴圈
- Less - 合併
- Less - 父選擇器
- 函式
- Less - 雜項函式
- Less - 字串函式
- Less - 列表函式
- Less - 數學函式
- Less - 型別函式
- Less - 顏色定義函式
- Less - 顏色通道函式
- Less - 顏色操作
- Less - 顏色混合函式
- 用法
- Less - 命令列用法
- 在瀏覽器中使用 Less
- Less - 瀏覽器支援
- Less - 外掛
- Less - 程式化用法
- Less - 線上編譯器
- Less - GUI
- Less - 編輯器和外掛
- Less - 第三方編譯器
- Less - 框架
- Less 有用資源
- Less - 快速指南
- Less - 有用資源
- Less - 討論
LESS - 註釋
描述
註釋使程式碼對使用者清晰易懂。您可以在程式碼中使用塊樣式和內聯註釋,但當您編譯 LESS 程式碼時,單行註釋不會出現在 CSS 檔案中。
示例
以下示例演示了在 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; }
輸出
請按照以下步驟檢視上述程式碼的工作原理:
將上述 html 程式碼儲存在 comments.html 檔案中。
在瀏覽器中開啟此 HTML 檔案,將顯示以下輸出。

廣告