W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗(yàn)值獎勵
@mixin 指令用于定義mixin,它可選地包括mixin名稱后面的變量和參數(shù)。
以下示例演示如何在SCSS文件中使用 @mixin :
<html> <head> <title> Mixin example of sass</title> <link rel="stylesheet" type="text/css" href="sample.css"/> </head> <body> <div class="cont"> <h1>Example using include</h1> <h3>Directive is used to define the Mixins, it includes variables and argument optionally.</h3> </div> </body> </html>
接下來,創(chuàng)建文件 sample.scss 。
@mixin style { .cont{ color: #77C1EF; } } @include style;
您可以通過使用以下命令讓SASS查看文件并在SASS文件更改時(shí)更新CSS:
sass --watch C:\ruby\lib\sass\sample.scss:sample.css
接下來執(zhí)行上面的命令,它將自動創(chuàng)建 sample.css 文件,代碼如下:
.cont { color: #77C1EF; }
讓我們執(zhí)行以下步驟,看看上面的代碼如何工作:
將上述html代碼保存在 sample.htm 文件中。
在瀏覽器中打開此HTML文件,將顯示如下輸出。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: