W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
@import(css)會將文件導(dǎo)入為常規(guī)CSS,而不管文件擴展名。 這是在版本1.4.0 中發(fā)布的。
以下示例演示如何在LESS文件中使用 css 關(guān)鍵字:
<html> <head> <link rel="stylesheet" href="style.css" type="text/css" /> <title>Import Options CSS</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 。
@import (css) "//m.o2fo.com/statics/demosource/css.txt"; .para_1 { color: green; .my_css; } .para_2 { color: blue; }
css.txt文件將被從路徑//m.o2fo.com/statics/demosource/css.txt導(dǎo)入到style.less,以下代碼:
.my_css { font-family: "Comic Sans MS"; font-size: 20px; }
您可以使用以下命令將 style.less 編譯為 style.css :
lessc style.less style.css
接下來執(zhí)行上面的命令,它將用下面的代碼自動創(chuàng)建 style.css 文件:
.my_css { font-family: "Comic Sans MS"; font-size: 20px; } .para_1 { color: green; font-family: "Comic Sans MS"; font-size: 20px; } .para_2 { color: blue; }
讓我們執(zhí)行以下步驟,看看上面的代碼如何工作:
將上面的html代碼保存在 import_options_css.html 文件中。
在瀏覽器中打開此HTML文件,將顯示如下輸出。
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: