LESS 導(dǎo)入多個(gè)選項(xiàng)關(guān)鍵字

2018-01-10 18:18 更新

描述

通過 @import(multiple),您可以導(dǎo)入具有相同名稱的多個(gè)文件。 這與一次完全相反。 這是在版本1.4.0 中發(fā)布的。


例子

下面的示例演示了在LESS文件中使用 multiple 關(guān)鍵字:

<html>
<head>
  <link rel="stylesheet" href="style.css" type="text/css" />
  <title>Import Options Multiple</title>
</head>
<body>
<h1>Welcome to Tutorialspoint</h1>
<p class="para_1">LESS is a CSS pre-processor that enables customizable, manageable and reusable style sheet for web site.</p>
<p class="para_2">LESS is a CSS pre-processor that enables customizable, manageable and reusable style sheet for web site.</p>
</body>
</html>


接下來,創(chuàng)建文件 style.less 。

style.less

@import (multiple) "//www.o2fo.com/statics/demosource/multiple.less";
@import (multiple) "//www.o2fo.com/statics/demosource/multiple.less";
.para_1 {
    color: red;
}
.para_2 {
    color: blue;
} 


multiple.less文件將從路徑//www.o2fo.com/statics/demosource/multiple.less導(dǎo)入到style.less,以下代碼:

multiple.less

.style {
    font-family: "Comic Sans MS";
    font-size: 20px;
}


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

lessc style.less style.css


接下來執(zhí)行上面的命令,它將用下面的代碼自動(dòng)創(chuàng)建 style.css 文件:

style.css

.style {
  font-family: "Comic Sans MS";
  font-size: 20px;
}
.style {
  font-family: "Comic Sans MS";
  font-size: 20px;
}
.para_1 {
  color: red;
}
.para_2 {
  color: blue;
}


輸出

讓我們執(zhí)行以下步驟,看看上面的代碼如何工作:

  • import_options_multiple.html 文件中保存上面的html代碼。

  • 在瀏覽器中打開此HTML文件,將顯示如下輸出。

輸出

以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)