2
2

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

横並びのときに高さがずれる問題の解決方法【inline-block】

Posted at

要素を横並びにするときに、今だとdisplay:flexが主流かなと思います。
でも、他にも要素を横並びにする方法はあって、その1つにinline-blockを使って横並びにする方法があります。

でも、inline-blockを使って横並びにすると1つぶつかる問題があって、それが高さがずれる問題です。
こちらみてみてください!

a41535e1fa625c41e0d5998b6afd93bd.png

このように、高さがずれてしまうんですよね。
これの原因がinline-blockvertical-alignの初期値がbase-lineだからです。

なので、高さを調節するためには、vertical-align: top;を指定すると高さがそろってくれます。

See the Pen inline-block by TakahiroOkada (@okalog) on CodePen.

2
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?