W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
每當(dāng)一個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>
接下來,創(chuàng)建文件 style.less 。
.outerMixin(@value) { .nestedMixin() { font-size: @value; } } .myclass { .outerMixin(30); .nestedMixin(); }
您可以使用以下命令將 style.less 編譯為 style.css :
lessc style.less style.css
接下來執(zhí)行上面的命令,它將用下面的代碼自動創(chuàng)建 style.css 文件:
.myclass { font-size: 30; }
讓我們執(zhí)行以下步驟,看看上面的代碼如何工作:
在 less_mixin_inside_mixin.html 文件中保存html代碼。
在瀏覽器中打開此HTML文件,將顯示如下輸出。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: