- 語言特性
- 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 - 顏色混合差值函式
描述
difference 函式逐通道地從第一個輸入顏色中減去第二個輸入顏色(注意負值會被反轉)。減去黑色顏色不會產生變化;減去白色顏色會導致顏色反轉。
引數
color1 − 一個充當被減數的顏色物件。
color2 − 一個充當減數的顏色物件。
返回值
顏色
示例
以下示例演示了在 LESS 檔案中使用difference 函式:
<html>
<head>
<link rel = "stylesheet" href = "style.css" type = "text/css" />
</head>
<body>
<h2>Difference Function</h2>
<div class = "color1">
<p>(color1) <br> #ff6600</p>
</div><br>
<div class = "color2">
<p>(color2) <br> #333333</p>
</div><br>
<div class = "res">
<p>(result) <br> #cc3333</p>
</div>
</body>
</html>
接下來,建立style.less檔案。
style.less
.color1 {
width: 100px;
height: 100px;
background-color: #ff6600;
}
.color2 {
width: 100px;
height: 100px;
background-color: #333333;
}
.res {
width: 100px;
height: 100px;
background-color: difference(#ff6600, #333333);
}
p {
padding: 30px 0px 0px 25px;
}
您可以使用以下命令將style.less編譯成style.css:
lessc style.less style.css
執行上述命令;它將自動建立包含以下程式碼的style.css檔案:
style.css
.color1 {
width: 100px;
height: 100px;
background-color: #ff6600;
}
.color2 {
width: 100px;
height: 100px;
background-color: #333333;
}
.result {
width: 100px;
height: 100px;
background-color: #cc3333;
}
p {
padding: 30px 0px 0px 25px;
}
輸出
請按照以下步驟檢視上述程式碼的工作方式:
將上述程式碼儲存到color_blending_difference.html檔案中。
在瀏覽器中開啟此 HTML 檔案,將顯示以下輸出。
less_color_blending_functions.htm
廣告