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?

More than 1 year has passed since last update.

左右要素は両端寄せ・中央要素を親に対して左右中央寄せ

Last updated at Posted at 2023-08-01

左右のボタンのwidthの影響を受けずに親に対して左右中央寄せする実装方法に少し迷ったのでメモ。

結論

See the Pen Center alignment with parents by Yuya Sasaki (@Yuya-SSK) on CodePen.

ポイントは以下。

  display: grid;
  grid-template-columns: 1fr auto 1fr;

  &__left-area {
    display: flex;
    justify-content: flex-start;
  }

  &__center-area {
    display: flex;
    justify-content: center;
  }

  &__right-area {
    display: flex;
    justify-content: flex-end;
  }

それぞれのボタンを内包する3つの領域を作り、grid-template-columnsで均等配置。
各領域に対して個別に寄せ設定。

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?