Tailwind CSS 填充

2022-08-15 10:51 更新

填充

用于設(shè)置 SVG 元素填充(fill)樣式的功能類。

Class
Properties
fill-current fill: currentColor;

使用

使用 ?fill-current? 將 SVG 的填充色設(shè)置為當(dāng)前的文本顏色。通過將該類與現(xiàn)有的文本顏色功能類相結(jié)合,可以輕松設(shè)置元素的填充顏色。

對(duì)于像 Zondicons 這樣完全用填充色繪制的圖標(biāo)集來說是很有用的:


自定義

通過自定義您的 ?tailwind.config.js? 文件的 ?theme.fill? 部分來控制 Tailwind 生成哪些 ?fill ?功能類。

  // tailwind.config.js
  module.exports = {
    theme: {
     fill: {
       current: 'currentColor',
     }
     fill: theme => ({
       'red': theme('colors.red.500'),
       'green': theme('colors.green.500'),
       'blue': theme('colors.blue.500'),
     })
    }
  }

變體

默認(rèn)情況下, 針對(duì) fill 功能類,只生成 responsive 變體。

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

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

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

禁用

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

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


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

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)