Vertically center elements in CSS

前端 未结 5 1238
醉酒成梦
醉酒成梦 2020-12-03 23:05

I have two elements side-by-side. Element 2 is smaller than Element 1. Both elements do not have a fixed height. I need to vertically center Element 2. How do I achieve

5条回答
  •  抹茶落季
    2020-12-04 00:01

    I don't think you can do this reliably without a table. Kevin's solution would probably work, unless you need to support IE (which most of us do). And, in this case, the table markup might actually be smaller than the div-based markup.

提交回复
热议问题