0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【React初心者メモ】gapとspaceの違い

Last updated at Posted at 2025-05-05

単純な横並びのアイテム(ボタン群など)には、space-*
折り返しを含むレスポンシブレイアウトやgrid構造では、gap-*

space-*

Flexbox専用で、子要素間のマージンを制御する
指定方法は、
space-x-<n>:横方向のスペース制御
space-y-<n>:縦方向のスペース制御

<div class="flex space-x-4">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>

gap-*

FlexboxとGrid両対応で、コンテナ内の要素の隙間を均等に制御します
指定方法は、
gap-<n>:行間と列間の両方を同時に設定
gap-x-<n>:列間のみを設定
gap-y-<n> :行間のみを設定

<div class="grid grid-cols-3 gap-4">
  <div>Item 1</div>
  <div>Item 2</div>
  <div>Item 3</div>
</div>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?