过滤
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>); |
示例(Examples)
¥Examples
基本示例(Basic example)
¥Basic example
使用 hue-rotate-90
和 hue-rotate-180
等工具按度旋转元素的色调:
¥Use utilities like hue-rotate-90
and hue-rotate-180
to rotate the hue of an element by degrees:
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" />
使用负值(Using negative values)
¥Using negative values
使用 -hue-rotate-15
和 -hue-rotate-45
等工具设置负色调旋转值:
¥Use utilities like -hue-rotate-15
and -hue-rotate-45
to set a negative hue rotate value:
-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" />
使用自定义值(Using a custom value)
¥Using a custom value
使用 hue-rotate-[<value>]
语法 根据完全自定义的值设置 hue rotation:
<img class="hue-rotate-[3.142rad] ..." src="/img/mountains.jpg" />
对于 CSS 变量,还可以使用 hue-rotate-(<custom-property>)
语法:
<img class="hue-rotate-(--my-hue-rotate) ..." src="/img/mountains.jpg" />
这只是简写,用于 hue-rotate-[var(<custom-property>)]
它会自动为你添加 var()
函数。
响应式设计(Responsive design)
¥Responsive design
在 filter: hue-rotate()
工具前面使用断点变体如 md:
仅在 medium 屏幕尺寸及以上时应用工具:
<img class="hue-rotate-60 md:hue-rotate-0 ..." src="/img/mountains.jpg" />
请参阅 变体文档 详细了解如何使用变体。