Less Screen顏色混合函數(shù)

2018-01-16 09:02 更新

描述

Screen功能使用兩種顏色作為參數(shù),并輸出較亮的顏色。

參數(shù):

  • color1:顏色對象。

  • color2:顏色對象。

返回:顏色。


例子

下面的示例演示了在LESS文件中使用 screen 函數(shù):

<html>
<head>
  <link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
<h2>Screen Function</h2>
<div class="color1">
  <p>(color1) <br> #ff6600</p>
</div><br>
<div class="color2">
  <p>(color2) <br> #0000ff</p>
</div><br>
<div class="res">
  <p>(result) <br> #ff66ff</p>
</div>
</body>
</html>


接下來,創(chuàng)建文件 style.less 。

style.less

.color1 {
    width: 100px;
    height: 100px;
    background-color: #ff6600;
}
.color2 {
    width: 100px;
    height: 100px;
    background-color: #0000ff;
}
.res {
    width: 100px;
    height: 100px;
    background-color: screen(#ff6600, #0000ff);
}
p{
 padding: 30px 0px 0px 25px;
}


您可以使用以下命令將 style.less 編譯為 style.css :

lessc style.less style.css


接下來執(zhí)行上面的命令,它將用下面的代碼自動創(chuàng)建 style.css 文件:

style.css

.color1 {
  width: 100px;
  height: 100px;
  background-color: #ff6600;
}
.color2 {
  width: 100px;
  height: 100px;
  background-color: #0000ff;
}
.result {
  width: 100px;
  height: 100px;
  background-color: #ff66ff;
}
p {
  padding: 30px 0px 0px 25px;
}


輸出

讓我們執(zhí)行以下步驟,看看上面的代碼如何工作:

  • 將上述代碼保存在 color_blending_screen.html 文件中。

  • 在瀏覽器中打開此HTML文件,將顯示如下輸出。


輸出

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號