Tailwind CSS Justify Self

2022-08-08 10:05 更新

Justify Self

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

Class
Properties
justify-self-auto justify-self: auto;
justify-self-start justify-self: start;
justify-self-end justify-self: end;
justify-self-center justify-self: center;
justify-self-stretch justify-self: stretch;

Auto

使用 ?justify-self-auto? 根據(jù)網(wǎng)格的 ?justify-items? 屬性的值來對齊一個項目:


<div class="grid justify-items-stretch ...">
  <!-- ... -->
  <div class="justify-self-auto ...">1</div>
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
</div>

Start

使用 ?justify-self-start? 將網(wǎng)格項沿內(nèi)聯(lián)軸起點對齊:


<div class="grid justify-items-stretch ...">
  <!-- ... -->
  <div class="justify-self-start ...">1</div>
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
</div>

Center

使用 ?justify-self-center? 將網(wǎng)絡(luò)項沿其內(nèi)聯(lián)軸的中心對齊。


<div class="grid justify-items-stretch ...">
  <!-- ... -->
  <div class="justify-self-center ...">1</div>
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
</div>

End

使用 ?justify-self-end? 將網(wǎng)格項沿內(nèi)聯(lián)軸終點對齊:


<div class="grid justify-items-stretch ...">
  <!-- ... -->
  <div class="justify-self-end ...">1</div>
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
</div>

Stretch

使用 ?justify-self-stretch? 來拉伸一個網(wǎng)格項,以填充其內(nèi)聯(lián)軸上的網(wǎng)格區(qū)域。


<div class="grid justify-items-start ...">
  <!-- ... -->
  <div class="justify-self-stretch ...">1</div>
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
  <!-- ... -->
</div>

響應式

要在特定的斷點處控制網(wǎng)格項在其網(wǎng)格區(qū)域內(nèi)的對齊,可以在任何現(xiàn)有的功能類前添加 ?{screen}:? 前綴。例如,使用 ?md:justify-self-end? 來僅在中等尺寸及以上的屏幕應用 ?justify-self-end? 功能。

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

自定義

變體

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

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

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

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

禁用

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

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


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

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號