當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Less hue()用法及代碼示例

較少色調函數提取 HSL 顏色空間中的色調通道。

色調函數示例

下麵舉個例子來演示一下Less文件中hue顏色通道的用法。

創建一個名為 ?simple.html? 的 HTML 文件,其中包含以下數據。

HTML 文件:simple.html

<!DOCTYPE html>
<html>
<head>
   <title>Hue Example</title>
   <link rel="stylesheet" type="text/css" href="simple.css"/>
</head>
<body>
   <h2>Example of hue color channel</h2>
   <div class="myclass">
   <p>background:75;</p>
   </div>
</body>
</html>

現在創建一個名為 "simple.less" 的文件。它類似於 CSS 文件。唯一的區別是它以 ".less" 擴展名保存。

LESS 文件:simple.less

.myclass{
   height:100px;
   width:100px;
   padding:30px 0px 0px 25px;
   background-color:(#b361b1);
   background:hue(hsl(75, 90%, 30%));
   color:white;
}

將文件 "simple.html" 和 "simple.less" 放在 Node.js 的根文件夾中

現在,執行以下代碼:lessc simple.less simple.css

Less hue1

這將編譯 "simple.less" 文件。將生成名為 "simple.css" 的 CSS 文件。

例如:

Less hue2

生成的 CSS "simple.css",代碼如下:

.myclass {
  height:100px;
  width:100px;
  padding:30px 0px 0px 25px;
  background-color:#b361b1;
  background:75;
  color:white;
}

輸出:

Less hue3



相關用法


注:本文由純淨天空篩選整理自 Less hue()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。