Less-import-options-multiple

提供:Dev Guides
移動先:案内検索

LESS-インポートオプションの複数のキーワード

説明

  • @ import(multiple)*キーワードを使用すると、同じ名前の複数のファイルをインポートできます。 これは、_once_とまったく逆に機能します。 これは_version 1.4.0_でリリースされました。

次の例は、LESSファイルでの_multiple_キーワードの使用を示しています-

<html>
   <head>
      <link rel = "stylesheet" href = "style.css" type = "text/css"/>
      <title>Import Options Multiple</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 (multiple) "http://www.finddevguides.com/less/multiple.less";
@import (multiple) "http://www.finddevguides.com/less/multiple.less";
.para_1 {
   color: red;
}

.para_2 {
   color: blue;
}

次のコードは、_multiple.less_ファイルをリンクから_style.less_にインポートします:/less/multiple.less [https://www.finddevguides.com/less/multiple.less]パス-

複数。

.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;
}

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

.para_1 {
   color: red;
}

.para_2 {
   color: blue;
}

出力

上記のコードがどのように機能するかを確認するには、次の手順に従ってください-

  • 上記のHTMLコードを import_options_multiplel ファイルに保存します。
  • このHTMLファイルをブラウザで開くと、次の出力が表示されます。

複数のLESSインポートオプション