filter: hue-rotate()
用于为元素应用色相旋转滤镜的工具类。
快速参考
| 类 | 属性 |
|---|---|
hue-rotate-<number> | filter: hue-rotate(<number>deg); |
-hue-rotate-<number> | filter: hue-rotate(calc(<number>deg * -1)); |
hue-rotate-(<custom-property>) | filter: hue-rotate(var(<custom-property>)); |
hue-rotate-[<value>] | filter: hue-rotate(<value>); |
示例
基础示例
使用 hue-rotate-90 和 hue-rotate-180 等工具类,按度数旋转元素的色相:
hue-rotate-15
hue-rotate-90
hue-rotate-180
hue-rotate-270
html
<!-- [!code classes:hue-rotate-15,hue-rotate-90,hue-rotate-180,hue-rotate-270] -->
<img class="hue-rotate-15" src="/img/mountains.jpg" />
<img class="hue-rotate-90" src="/img/mountains.jpg" />
<img class="hue-rotate-180" src="/img/mountains.jpg" />
<img class="hue-rotate-270" src="/img/mountains.jpg" />使用负值
使用 -hue-rotate-15 和 -hue-rotate-45 等工具类设置负的色相旋转值:
-hue-rotate-15
-hue-rotate-45
-hue-rotate-90
html
<!-- [!code classes:-hue-rotate-15,-hue-rotate-45,-hue-rotate-90] -->
<img class="-hue-rotate-15" src="/img/mountains.jpg" />
<img class="-hue-rotate-45" src="/img/mountains.jpg" />
<img class="-hue-rotate-90" src="/img/mountains.jpg" />使用自定义值
使用 hue-rotate-[<value>] 等工具类,基于完全自定义的值设置色相旋转:
html
<img class="hue-rotate-[3.142rad] ..." />对于 CSS 变量,也可以使用 hue-rotate-(<custom-property>) 语法:
html
<img class="hue-rotate-(--my-hue-rotate) ..." />这只是 hue-rotate-[var(<custom-property>)] 的简写,会自动为你加上 var() 函数。
响应式设计
使用 md: 等断点变体作为 filter: hue-rotate() 工具类的前缀,即可仅在中等及以上屏幕尺寸时应用该工具类:
html
<img class="hue-rotate-60 md:hue-rotate-0 ..." />在变体文档中了解更多关于使用变体的信息。