- 語言特性
- LESS - 巢狀規則
- LESS - 巢狀指令和冒泡
- LESS - 運算
- LESS - 轉義
- LESS - 函式
- LESS - 名稱空間和訪問器
- LESS - 作用域
- LESS - 註釋
- LESS - 匯入
- LESS - 變數
- LESS - 繼承 (Extend)
- LESS - Mixin (混入)
- LESS - 引數化Mixin
- LESS - Mixin作為函式
- LESS - 向Mixin傳遞規則集
- LESS - 匯入指令
- LESS - 匯入選項
- LESS - Mixin 保護
- LESS - CSS 保護
- LESS - 迴圈
- LESS - 合併 (Merge)
- LESS - 父選擇器
- 函式
- LESS - 其他函式
- LESS - 字串函式
- LESS - 列表函式
- LESS - 數學函式
- LESS - 型別函式
- LESS - 顏色定義函式
- LESS - 顏色通道函式
- LESS - 顏色運算
- LESS - 顏色混合函式
- 使用
- LESS - 命令列使用
- 在瀏覽器中使用LESS
- LESS - 瀏覽器支援
- LESS - 外掛
- LESS - 程式化使用
- LESS - 線上編譯器
- LESS - 圖形使用者介面
- LESS - 編輯器和外掛
- LESS - 第三方編譯器
- LESS - 框架
- LESS 有用資源
- LESS - 快速指南
- LESS - 有用資源
- LESS - 討論
LESS - 匯入
描述
它用於匯入LESS或CSS檔案的內容。
示例
以下示例演示了在LESS檔案中使用匯入:
<html>
<head>
<title>Less Importing</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<h1>Example using Importing</h1>
<p class = "myclass">LESS enables customizable,
manageable and reusable style sheet for web site.</p>
<p class = "myclass1">It allows reusing CSS code and
writing LESS code with same semantics.</p>
<p class = "myclass2">LESS supports creating cleaner,
cross-browser friendly CSS faster and easier.</p>
</body>
</html>
現在建立 *myfile.less* 檔案。
myfile.less
.myclass {
color: #FF8000;
}
.myclass1 {
color: #5882FA;
}
現在建立 *style.less* 檔案。
style.less
@import "https://tutorialspoint.tw/less/myfile.less";
.myclass2 {
color: #FF0000;
}
*myfile.less* 檔案將從路徑 https://tutorialspoint.tw/less/myfile.less 匯入到 *style.less* 中。
您可以使用以下命令將 *style.less* 檔案編譯成 *style.css*:
lessc style.less style.css
執行上述命令;它將自動建立包含以下程式碼的 *style.css* 檔案:
style.css
.myclass {
color: #FF8000;
}
.myclass1 {
color: #5882FA;
}
.myclass2 {
color: #FF0000;
}
輸出
按照以下步驟檢視上述程式碼的工作方式:
將上述HTML程式碼儲存在 **importing.html** 檔案中。
在瀏覽器中開啟此HTML檔案,將顯示以下輸出。
廣告