Less-greyscale
提供:Dev Guides
少ない-グレースケール
説明
選択した要素の色から彩度を破棄します。 次のパラメータがあります-
- color -色オブジェクトを表します。
例
次の例は、LESSファイルでのグレースケールカラー操作の使用を示しています-
<html>
<head>
<title>Greyscale</title>
<link rel = "stylesheet" type = "text/css" href = "style.css"/>
</head>
<body>
<h2>Example of Greyscale Color Operation</h2>
<div class = "myclass1">
<p>color :<br>#426105</p>
</div><br>
<div class = "myclass2">
<p>result :<br>#333333</p>
</div>
</body>
</html>
次に、_style.less_ファイルを作成します。
style.less
.myclass1 {
height:100px;
width:100px;
padding: 30px 0px 0px 25px;
background-color: hsl(80, 90%, 20%);
color:white;
}
.myclass2 {
height:100px;
width:100px;
padding: 30px 0px 0px 25px;
background-color: greyscale(hsl(80, 90%, 20%));
color:white;
}
次のコマンドを使用して、_style.less_を_style.css_にコンパイルできます-
lessc style.less style.css
上記のコマンドを実行します。それは次のコードで自動的に_style.css_ファイルを作成します-
style.css
.myclass1 {
height: 100px;
width: 100px;
padding: 30px 0px 0px 25px;
background-color: #426105;
color: white;
}
.myclass2 {
height: 100px;
width: 100px;
padding: 30px 0px 0px 25px;
background-color: #333333;
color: white;
}
出力
上記のコードがどのように機能するかを確認するには、次の手順に従ってください-
- 上記のHTMLコードを greyscalel ファイルに保存します。
- このHTMLファイルをブラウザで開くと、次の出力が表示されます。