Tailwind CSS Hue Rotate

2022-08-10 11:31 更新

Hue Rotate

將色調(diào)旋轉(zhuǎn)濾鏡應(yīng)用于元素的實用程序。

Class
Properties
-hue-rotate-180 --tw-hue-rotate: hue-rotate(-180deg);
-hue-rotate-90 --tw-hue-rotate: hue-rotate(-90deg);
-hue-rotate-60 --tw-hue-rotate: hue-rotate(-60deg);
-hue-rotate-30 --tw-hue-rotate: hue-rotate(-30deg);
-hue-rotate-15 --tw-hue-rotate: hue-rotate(-15deg);
hue-rotate-0 --tw-hue-rotate: hue-rotate(0deg);
hue-rotate-15 --tw-hue-rotate: hue-rotate(15deg);
hue-rotate-30 --tw-hue-rotate: hue-rotate(30deg);
hue-rotate-60 --tw-hue-rotate: hue-rotate(60deg);
hue-rotate-90 --tw-hue-rotate: hue-rotate(90deg);
hue-rotate-180 --tw-hue-rotate: hue-rotate(180deg);

用法

在 ?filter ?實用程序旁邊使用 ?hue-rotate-{amount}? 實用程序來旋轉(zhuǎn)元素的色調(diào)。

<div class="filter hue-rotate-15 ...">
  <!-- ... -->
</div>

響應(yīng)式

要在特定斷點處控制元素的色調(diào)旋轉(zhuǎn),請在任何現(xiàn)有的色調(diào)旋轉(zhuǎn)實用程序中添加 ?{screen}:? 前綴。例如,使用 ?md:hue-rotate-60? 將 ?hue-rotate-60? 實用程序僅應(yīng)用于中等大小及以上的屏幕尺寸。

<div class="filter hue-rotate-15 md:hue-rotate-60 ...">
  <!-- ... -->
</div>

有關(guān) Tailwind 響應(yīng)式設(shè)計功能的更多信息,請查看響應(yīng)式設(shè)計文檔。

自定義

您可以使用 ?tailwind.config.js? 文件的主題部分中的 ?hueRotate ?鍵自定義生成哪些 ?hue-rotate? 實用程序。

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

主題自定義文檔中了解有關(guān)自定義默認主題的更多信息。

變體

默認情況下, 針對 hue-rotate 功能類,只生成 responsive 變體。

您可以通過修改您的 ?tailwind.config.js? 文件中的 ?variants ?部分中的 ?hueRotate ?屬性來控制為 hue-rotate 功能生成哪些變體。

例如,這個配置也將生成 hover and focus 變體:

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

禁用

如果您不打算在您的項目中使用 hue-rotate 功能,您可以通過在配置文件的 ?corePlugins ?部分將 ?hueRotate ?屬性設(shè)置為 ?false ?來完全禁用它們:

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


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號