Skip to content
全部文档

backdrop-filter: hue-rotate()

用于为元素应用背景色相旋转滤镜的工具类。

快速参考

属性
backdrop-hue-rotate-<number>backdrop-filter: hue-rotate(<number>deg);
-backdrop-hue-rotate-<number>backdrop-filter: hue-rotate(calc(<number>deg * -1));
backdrop-hue-rotate-(<custom-property>)backdrop-filter: hue-rotate(var(<custom-property>));
backdrop-hue-rotate-[<value>]backdrop-filter: hue-rotate(<value>);

示例

基础示例

使用 backdrop-hue-rotate-90backdrop-hue-rotate-180 等工具类旋转元素背景的色相:

backdrop-hue-rotate-90

backdrop-hue-rotate-180

backdrop-hue-rotate-270

html
<!-- [!code classes:backdrop-hue-rotate-90,backdrop-hue-rotate-180,backdrop-hue-rotate-270] -->
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 backdrop-hue-rotate-90 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 backdrop-hue-rotate-180 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 backdrop-hue-rotate-270 ..."></div>
</div>

使用负值

使用 -backdrop-hue-rotate-90-backdrop-hue-rotate-180 等工具类设置负的背景色相旋转值:

-backdrop-hue-rotate-15

-backdrop-hue-rotate-45

-backdrop-hue-rotate-90

html
<!-- [!code classes:-backdrop-hue-rotate-15,-backdrop-hue-rotate-45,-backdrop-hue-rotate-90] -->
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 -backdrop-hue-rotate-15 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 -backdrop-hue-rotate-45 ..."></div>
</div>
<div class="bg-[url(/img/mountains.jpg)]">
  <div class="bg-white/30 -backdrop-hue-rotate-90 ..."></div>
</div>

使用自定义值

使用 backdrop-hue-rotate-[<value>] 等工具类,基于完全自定义的值设置背景色相旋转:

html
<div class="backdrop-hue-rotate-[3.142rad] ...">
 <!-- ... -->
</div>

对于 CSS 变量,也可以使用 backdrop-hue-rotate-(<custom-property>) 语法:

html
<div class="backdrop-hue-rotate-(--my-backdrop-hue-rotation) ...">
 <!-- ... -->
</div>

这只是 backdrop-hue-rotate-[var(<custom-property>)] 的简写,会自动为你加上 var() 函数。

响应式设计

使用 md: 等断点变体作为 backdrop-filter: hue-rotate() 工具类的前缀,即可仅在中等及以上屏幕尺寸时应用该工具类:

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

变体文档中了解更多关于使用变体的信息。

文档译文以 MIT 协议授权;原文版权归 Tailwind Labs。湘ICP备2026005453号-2