- 語言特性
- LESS - 巢狀規則
- LESS - 巢狀指令和冒泡
- LESS - 運算
- LESS - 轉義
- LESS - 函式
- LESS - 名稱空間和訪問器
- LESS - 作用域
- LESS - 註釋
- LESS - 匯入
- LESS - 變數
- LESS - 擴充套件
- LESS - Mixin(混入)
- LESS - 引數化Mixin
- LESS - Mixin作為函式
- LESS - 向Mixin傳遞規則集
- LESS - 匯入指令
- LESS - 匯入選項
- LESS - Mixin 保護
- LESS - CSS 保護
- LESS - 迴圈
- LESS - 合併
- LESS - 父選擇器
- 函式
- LESS - 其他函式
- LESS - 字串函式
- LESS - 列表函式
- LESS - 數學函式
- LESS - 型別函式
- LESS - 顏色定義函式
- LESS - 顏色通道函式
- LESS - 顏色運算
- LESS - 顏色混合函式
- 用法
- LESS - 命令列用法
- 在瀏覽器中使用LESS
- LESS - 瀏覽器支援
- LESS - 外掛
- LESS - 程式化用法
- LESS - 線上編譯器
- LESS - 圖形使用者介面
- LESS - 編輯器和外掛
- LESS - 第三方編譯器
- LESS - 框架
- LESS 有用資源
- LESS - 快速指南
- LESS - 有用資源
- LESS - 討論
LESS - 色彩陰影
描述
它用於將顏色與黑色混合,降低顏色的比例。它具有以下引數:
顏色 - 它表示一個顏色物件。
權重 - 這是一個可選引數,它透過提供顏色和黑色之間的百分比平衡點來指定元素的權重。
示例
以下示例演示了在 LESS 檔案中使用陰影顏色運算:
<html>
<head>
<title>Shade</title>
<link rel = "stylesheet" type = "text/css" href = "style.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>
接下來,建立style.less檔案。
style.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;
}
您可以使用以下命令將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: 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;
}
輸出
按照以下步驟檢視以上程式碼的工作原理:
將以上HTML程式碼儲存到shade.html檔案中。
在瀏覽器中開啟此HTML檔案,將顯示以下輸出。
less_color_operation.htm
廣告