1. 过滤
  2. hue-rotate

过滤

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)

基本示例(Basic example)

使用像 hue-rotate-90hue-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)

使用像 -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)

使用 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)

filter: hue-rotate() 工具前面使用断点变体如 md: 仅在 medium 屏幕尺寸及以上时应用工具:

<img class="hue-rotate-60 md:hue-rotate-0 ..." src="/img/mountains.jpg" />

请参阅 变体文档 详细了解如何使用变体。

TailwindCSS 中文网 - 粤ICP备13048890号