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