阅读(2903) (0)

Tailwind CSS Backdrop Hue Rotate

2022-07-25 17:30:30 更新

Backdrop Hue Rotate

用于将背景色相旋转滤镜应用于元素的实用程序。

Class
Properties
-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);

用法

使用 ​background-hue-rotate-{amount}​ 实用程序和 ​backdrop-filter​ 实用程序来旋转元素背景的色调。

<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.js​ 文件的 ​theme ​部分中的 ​backgroundHueRotate ​键自定义生成哪些 ​backdrop-hue-rotate​ 实用程序。

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

主题自定义文档中了解有关自定义默认主题的更多信息。

变体

默认情况下, 针对 backdrop hue-rotate 功能类,只生成 responsive 变体。

您可以通过修改您的 ​tailwind.config.js​ 文件中的 ​variants ​部分中的 ​backdropHueRotate ​属性来控制为 backdrop hue-rotate 功能生成哪些变体。

例如,这个配置也将生成 hover and focus 变体:

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

禁用

如果您不打算在您的项目中使用 backdrop hue-rotate 功能,您可以通过在配置文件的 ​corePlugins ​部分将 ​backdropHueRotate ​属性设置为 ​false ​来完全禁用它们:

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