減少陰影函數用於在減少顏色比例時將顏色與黑色混合。用於陰影顏色操作的參數是:
- color:它用於指定顏色對象。
- weight:它是一個可選參數,用於通過提供顏色和白色之間的百分比平衡點來指定元素的權重。
陰影函數示例
下麵通過一個例子來演示Less文件中陰影顏色操作的用法。
創建名為 "simple.html" 的 HTML 文件,其中包含以下數據。
HTML 文件:simple.html
<!DOCTYPE html>
<html>
<head>
<title>Shade Example</title>
<link rel="stylesheet" type="text/css" href="simple.css"/>
</head>
<body>
<h2>Example of Shade Color Operation</h2>
<div class="myclass1">
<p>color:<br>rgba(66, 97, 5, 0.5)</p>
</div><br>
<div class="myclass2">
<p>result:<br>rgba(17, 24, 1, 0.75)</p>
</div>
</body>
</html>
現在創建一個名為 "simple.less" 的文件。它類似於 CSS 文件。唯一的區別是它以 ".less" 擴展名保存。
LESS 文件:simple.less
.myclass1{
height:100px;
width:100px;
padding:30px 0px 0px 25px;
background-color:rgba(66, 97, 5, 0.5);
color:white;
}
.myclass2{
height:100px;
width:100px;
padding:30px 0px 0px 25px;
background-color:shade(rgba(66, 97, 5, 0.5),50%);
color:white;
}
將文件 "simple.html" 和 "simple.less" 放在 Node.js 的根文件夾中
現在,執行以下代碼:lessc simple.less simple.css

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

生成的 CSS "simple.css",代碼如下:
.myclass1 {
height:100px;
width:100px;
padding:30px 0px 0px 25px;
background-color:rgba(66, 97, 5, 0.5);
color:white;
}
.myclass2 {
height:100px;
width:100px;
padding:30px 0px 0px 25px;
background-color:rgba(17, 24, 1, 0.75);
color:white;
}
輸出:

相關用法
- Less saturation()用法及代碼示例
- Less sin()用法及代碼示例
- Less sqrt()用法及代碼示例
- Less spin()用法及代碼示例
- Less isstring()用法及代碼示例
- Less image-width()用法及代碼示例
- Less alpha()用法及代碼示例
- Less max()用法及代碼示例
- Less ispixel()用法及代碼示例
- Less acos()用法及代碼示例
- Less contrast()用法及代碼示例
- Less isem()用法及代碼示例
- Less hsvhue()用法及代碼示例
- Less color()用法及代碼示例
- Less isnumber()用法及代碼示例
- Less percentage()用法及代碼示例
- Less pi()用法及代碼示例
- Less red()用法及代碼示例
- Less image-height()用法及代碼示例
- Less iscolor()用法及代碼示例
注:本文由純淨天空篩選整理自 Less shade()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。