2
1

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 3 years have passed since last update.

CSSだけでPinterest風レイアウトを作る

Last updated at Posted at 2022-03-14

概要

layout.png

失敗例

(実行結果が見にくいのでCodePenに移動するか下部の「0.5x」ボタンを押してください)

See the Pen column-layout_00 by reona396 (@reona396) on CodePen.

一見実装できているように見えるが、一番最後のハムスターのカードに文章が1文増えると…

See the Pen column-layout_01 by reona396 (@reona396) on CodePen.

レイアウトが崩れ、カードボックスとフッターの間に大きく余白ができてしまう。

実装例

See the Pen column-layout_02 by reona396 (@reona396) on CodePen.

  • carddisplay: inline-block ではなく display: block に変更
  • card の下部の余白を margin-bottom で調整するのではなく、
    card の外側に配置した card-wrapperpadding-bottom で調整する
  • カードの並び全体を中央揃えにするため、 card-box の外側に card-box-wrapper を配置して display: flex で調整
  • カード列の余白を調整するため、 card-boxcolumn-gap を調整
2
1
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
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?