Tailwind CSS 文本轉(zhuǎn)換

2022-08-04 10:11 更新

文本轉(zhuǎn)換

用于控制文本轉(zhuǎn)換的功能類。

Class
Properties
uppercase text-transform: uppercase;
lowercase text-transform: lowercase;
capitalize text-transform: capitalize;
normal-case text-transform: none;

Normal Case

使用 ?normal-case? 功能類來保留原來的外殼,這通常用于在不同的斷點處重置大寫。


<p class="normal-case ...">The quick brown fox ...</p>

Uppercase

使用 ?uppercase ?功能類對文本進行大寫轉(zhuǎn)換。


<p class="uppercase ...">The quick brown fox ...</p>

Lowercase

使用 ?lowercase ?功能類對文本進行小寫轉(zhuǎn)換。


<p class="lowercase ...">The quick brown fox ...</p>

Capitalize

使用 ?capitalize ?功能類對文本進行首字母大寫轉(zhuǎn)換。


<p class="capitalize ...">The quick brown fox ...</p>

響應(yīng)式

要在特定的斷點處控制元素的文本轉(zhuǎn)換,可在任何現(xiàn)有的文本轉(zhuǎn)換功能類中添加 ?{screen}:? 前綴。例如,使用 ?md:uppercase? 來應(yīng)用 ?uppercase ?功能類在中等大小的屏幕和更大的屏幕上。

<p class="capitalize md:uppercase ...">
  The quick brown fox jumps over the lazy dog.
</p>

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

自定義

變體

默認情況下, 針對 text transformation 功能類,只生成 responsive 變體。

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

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

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

設(shè)計

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

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


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號