你正在瀏覽的是 Tailwind CSS v2. 的技術文件
Tailwind CSS 的 GitHub

Backdrop Hue Rotate (背景色相旋轉)

Tailwind CSS version
v2.1+

將背景色相濾鏡套用在元素的功能

Default class reference

Class
屬性
-backdrop-hue-rotate-180--tw-backdrop-hue-rotate: hue-rotate(-180deg);
-backdrop-hue-rotate-90--tw-backdrop-hue-rotate: hue-rotate(-90deg);
-backdrop-hue-rotate-60--tw-backdrop-hue-rotate: hue-rotate(-60deg);
-backdrop-hue-rotate-30--tw-backdrop-hue-rotate: hue-rotate(-30deg);
-backdrop-hue-rotate-15--tw-backdrop-hue-rotate: hue-rotate(-15deg);
backdrop-hue-rotate-0--tw-backdrop-hue-rotate: hue-rotate(0deg);
backdrop-hue-rotate-15--tw-backdrop-hue-rotate: hue-rotate(15deg);
backdrop-hue-rotate-30--tw-backdrop-hue-rotate: hue-rotate(30deg);
backdrop-hue-rotate-60--tw-backdrop-hue-rotate: hue-rotate(60deg);
backdrop-hue-rotate-90--tw-backdrop-hue-rotate: hue-rotate(90deg);
backdrop-hue-rotate-180--tw-backdrop-hue-rotate: hue-rotate(180deg);

用法

Use the backdrop-hue-rotate-{amount} utilities alongside the backdrop-filter utility to rotate the hue of an element’s backdrop.

<div class="backdrop-filter backdrop-hue-rotate-15 ...">
  <!-- ... -->
</div>

響應式

如要讓元素的背景色相旋轉有響應式效果,可在現有背景色相旋轉功能前加上前綴詞 {screen}: 。例如:中型或以上的螢幕尺寸使用 md:backdrop-hue-rotate-60 以套用 backdrop-hue-rotate-60 功能。

<div class="backdrop-filter backdrop-hue-rotate-15 md:backdrop-hue-rotate-60 ...">
  <!-- ... -->
</div>

更多有關 Tailwind 響應式設計功能的資訊,可參考 響應式設計 文件。

客製化

你可以在tailwind.config.jstheme區塊中,使用backdropHueRotate這個 key 來客製化你要的backdrop-hue-rotate效果。

  // tailwind.config.js
  module.exports = {
    theme: {
+     extend: {
+       backdropHueRotate: {
+         '-270': '-270deg',
+         270: '270deg',
+       }
+     }
    }
  }

更多有關客製化預設主題的資訊,可參考主題客製化文件

變化模式

默認情況下, 只有 響應式 的 backdrop hue-rotate 變化模式 (variants) 會產生。

tailwind.config.jsvariants 區塊中變更 backdropHueRotate 屬性來決定有哪些變化模式會生成。

舉個例子來說,這個設定將會生成 響應式 和 hover 的變化模式。

  // tailwind.config.js
  module.exports = {
    variants: {
      extend: {
        // ...
+       backdropHueRotate: ['responsive', 'hover'],
      }
    }
  }

停用

如果你不打算在專案中使用 backdrop hue-rotate 功能,可以在你的設定檔裡的 corePlugins 屬性中將 backdropHueRotate 設定為 false 來停用功能:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
+     backdropHueRotate: false,
    }
  }