Less教程
Less函数

Less shade()

Less shade()

Less shade函数用于在降低颜色比例时将颜色与黑色混合。用于阴影颜色操作的参数为:
color: 它用于指定颜色对象。 weight: 这是一个可选参数,用于通过提供颜色和白色之间的百分比平衡点来指定元素的重量。

阴影功能示例

我们以一个示例来演示Less文件中阴影颜色操作的用法。
创建一个名为"simple.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
less -shade-function1
这将编译"simple.less " 文件。将生成一个名为" simple.css"的CSS文件。
例如:
Less-shade-function2
生成的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 -shade-function3
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4