LESS - 合併逗號



描述

它將屬性值新增到最後。

示例

以下示例演示了在 LESS 檔案中使用合併逗號功能:

<!doctype html>
   <head>
      <title>Merge Comma</title>
      <link rel = "stylesheet" href = "style.css" type = "text/css" />
   </head>

   <body>
      <h2>Example of Merge Comma</h2>
      <p class = "class">Hello World!!!Welcome to Tutorialspoint...</p>
   </body>
</html>

接下來,建立style.less檔案。

style.less

.myfunc() {
   box-shadow+: 5px 5px 5px grey;
}

.class {
   .myfunc();
   box-shadow+: 0 0 5px #f78181;
}

您可以使用以下命令將style.less編譯為style.css

lessc style.less style.css

執行上述命令;它將自動建立包含以下程式碼的style.css檔案:

style.css

.class {
   box-shadow: 5px 5px 5px grey, 0 0 5px #f78181;
}

輸出

按照以下步驟檢視上述程式碼的工作原理:

  • 將上述 html 程式碼儲存在merge_comma.html檔案中。

  • 在瀏覽器中開啟此 HTML 檔案,將顯示以下輸出。

Merge
less_merge.htm
廣告

© . All rights reserved.