Less-import-options-less
提供:Dev Guides
LESS-インポートオプション少ないキーワード
説明
- @ import(less)*は、ファイルの拡張子に関係なく、LESSファイルとしてファイルをインポートします。 これは_version 1.4.0_でリリースされました。
例
次の例は、LESSファイルでの_less_キーワードの使用を示しています-
<html>
<head>
<link rel = "stylesheet" href = "style.css" type = "text/css"/>
<title>Import Options Less</title>
</head>
<body>
<h1>Welcome to finddevguides</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>
次に、_style.less_ファイルを作成します。
style.less
@import (less) "http://www.finddevguides.com/less/less.txt";
.para_1 {
color: red;
.style;
}
.para_2 {
color: blue;
}
次のコードはless.txtファイルをリンクからstyle.lessにインポートします:/less/less.txt [https://www.finddevguides.com/less/less.txt]パス-
less.txt
.style {
font-family: "Comic Sans MS";
font-size: 20px;
}
次のコマンドを使用して、_style.less_を_style.css_にコンパイルできます-
lessc style.less style.css
上記のコマンドを実行します。それは次のコードで自動的に_style.css_ファイルを作成します-
style.css
.style {
font-family: "Comic Sans MS";
font-size: 20px;
}
.para_1 {
color: red;
font-family: "Comic Sans MS";
font-size: 20px;
}
.para_2 {
color: blue;
}
出力
上記のコードがどのように機能するかを確認するには、次の手順に従ってください-
- 上記のHTMLコードを import_options_lessl ファイルに保存します。
- このHTMLファイルをブラウザで開くと、次の出力が表示されます。