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.

HTML/CSS 項目の横並べ

Posted at

ホームページを作るうえで必ず出る項目の横並べ

よく使われるコードを記載します

flexbox

これが一番良い

See the Pen Untitled by はーと (@spite400k) on CodePen.

float

これが一番不便。。。

See the Pen Untitled by はーと (@spite400k) on CodePen.

  • floatを指定した要素の親要素に高さ反映されなくなってしまう
    →heightを50pxに指定
  • 幅が大きくなって3つ目が次行に回される
    →子要素にbox-sizing: border-boxを指定して、borderを含めて幅計算するようにする
       ただしmarginは考慮されないため、marginを減らすか、widthの33%→30%に減らす必要あり

display:table-cell

See the Pen Untitled by はーと (@spite400k) on CodePen.

  • display: table-cellの場合、marginが効かない
     →「border-collapse」「border-spacing」で間隔をあける
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?