LESS - 淡出



描述

它降低所選元素的不透明度。它具有以下引數:

  • 顏色 - 它表示顏色物件。

  • 數量 - 它包含 0 - 100% 之間的百分比。

  • 方法 - 這是一個可選引數,用於透過將其設定為相對來調整相對於當前值。

示例

以下示例演示了在 LESS 檔案中使用 fadeout 顏色操作:

<html>
   <head>
      <title>Fadeout</title>
      <link rel = "stylesheet" type = "text/css" href = "style.css"/>
   </head>

   <body>
      <h2>Example of Fadeout 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(66, 97, 5, 0.4)</p>
      </div>
   </body>
</html>

接下來,建立style.less檔案。

style.less

.myclass1 {
   height:100px;
   width:100px;
   padding: 30px 0px 0px 25px;
   background-color: hsla(80, 90%, 20%,0.5);
   color:white;
}

.myclass2 {
   height:100px;
   width:100px;
   padding: 30px 0px 0px 25px;
   background-color: fadeout(hsla(80, 90%, 20%,0.5), 10%);
   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(66, 97, 5, 0.4);
   color: white;
}

輸出

請按照以下步驟檢視以上程式碼的工作原理:

  • 將以上 html 程式碼儲存在fadeout.html檔案中。

  • 在瀏覽器中開啟此 HTML 檔案,將顯示以下輸出。

Less Fadeout
less_color_operation.htm
廣告

© . All rights reserved.