Tailwind CSS Justify Items

2022-09-15 09:07 更新

Justify Items

用于控制網(wǎng)格項(xiàng)目如何沿其內(nèi)聯(lián)軸對(duì)齊的功能類。

Class
Properties
justify-items-start justify-items: start;
justify-items-end justify-items: end;
justify-items-center justify-items: center;
justify-items-stretch justify-items: stretch;

Start

使用 ?justify-items-start? 使網(wǎng)格項(xiàng)目沿內(nèi)聯(lián)軸的起點(diǎn)排列。


<div class="grid justify-items-start ...">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

End

使用 ?justify-items-end? 使網(wǎng)格項(xiàng)目沿內(nèi)聯(lián)軸的終點(diǎn)排列。


<div class="grid justify-items-end ...">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

Center

使用 ?justify-items-center? 使風(fēng)格項(xiàng)目沿著他們的內(nèi)聯(lián)軸對(duì)齊。


<div class="grid justify-items-center ...">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

Stretch

使用 ?justify-items-stretch? 沿其內(nèi)聯(lián)軸拉伸項(xiàng)目。


<div class="grid justify-items-stretch ...">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

響應(yīng)式

要在特定的斷點(diǎn)處對(duì) flex 項(xiàng)目應(yīng)用 justify 功能類,請(qǐng)?jiān)谌魏维F(xiàn)有的功能類前添加 ?{screen}:? 前綴。例如,使用 ?md:justify-items-center? 來(lái)僅在中等尺寸以上的屏幕應(yīng)用 ?justify-items-center? 功能類。

<div class="justify-items-start md:justify-items-center">
  <!-- ... -->
</div>

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

自定義

變體

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

您可以通過(guò)修改您的 ?tailwind.config.js? 文件中的 ?variants ?部分中的 ?justifyItems ?屬性來(lái)控制為 justify-items 功能生成哪些變體。

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

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

禁用

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

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


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

掃描二維碼

下載編程獅App

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

編程獅公眾號(hào)