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?

Taliwindで要素を真ん中寄せ

Posted at

要素を真ん中に寄せたい時、下記のコードで実現できます。

①要素をflexに設定
②縦軸と横軸を中心に設定(items-center justify-center)
③flexの高さの最小を画面の高さに設定(min-h-screen)

image.png

  return (
    <div className = "flex items-center justify-center bg-gray-700  min-h-screen ">
      <Card >
        <CardContent>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
        </CardContent>
      </Card>
      <Card >
        <CardContent>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
        </CardContent>
      </Card>
      <Card >
        <CardContent>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
        </CardContent>
      </Card>
      <Card >
        <CardContent>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
          <p>テストだよ</p>
        </CardContent>
      </Card>
    </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?