
- 語言特性
- LESS - 巢狀規則
- LESS - 巢狀指令和冒泡
- LESS - 運算
- LESS - 轉義
- LESS - 函式
- LESS - 名稱空間和訪問器
- LESS - 作用域
- LESS - 註釋
- LESS - 匯入
- LESS - 變數
- LESS - 擴充套件
- LESS - Mixin
- LESS - 引數化Mixin
- LESS - Mixin作為函式
- LESS - 向Mixin傳遞規則集
- LESS - 匯入指令
- LESS - 匯入選項
- LESS - Mixin 保護
- 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 - Mixin巢狀
描述
當在一個Mixin內部定義另一個Mixin時,它也可以用作返回值。
示例
以下示例演示了在LESS檔案中使用Mixin巢狀:
<html> <head> <link rel = "stylesheet" href = "style.css" type = "text/css" /> <title>Mixin inside mixin</title> </head> <body> <h1>Welcome to Tutorialspoint</h1> <div class = "myclass"> <p>LESS is a CSS pre-processor that enables customizable, manageable and reusable style sheet for web site.</p> </div> </body> </html>
接下來,建立style.less檔案。
style.less
.outerMixin(@value) { .nestedMixin() { font-size: @value; } } .myclass { .outerMixin(30); .nestedMixin(); }
您可以使用以下命令將style.less編譯為style.css:
lessc style.less style.css
執行上述命令;它將自動建立包含以下程式碼的style.css檔案:
style.css
.myclass { font-size: 30; }
輸出
按照以下步驟檢視上述程式碼的工作原理:
將上述html程式碼儲存在less_mixin_inside_mixin.html檔案中。
在瀏覽器中開啟此HTML檔案,將顯示以下輸出。

less_mixins_as_functions.htm
廣告