Tony the Pony
Tony the Pony

Reputation: 41347

How to vertically center inline elements in CSS

This may seem like a silly question, but I am not getting the expected results from vertical-align. So…

  1. Does vertical-align:center center the child items of the item that has this property, or does it center the item itself that has this property, within its parent?

  2. To me, “center” means the distances between the item’s top margin and the container’s top padding, and the item’s bottom margin and the container’s bottom padding are the same. This doesn’t seem to always be the case. Is the “bottom” of an inline element the baseline of the text?

Thanks!

Upvotes: 1

Views: 590

Answers (1)

Hoàng Long
Hoàng Long

Reputation: 10848

Please take a look here: http://www.w3schools.com/css/pr_pos_vertical-align.asp

According to that, vertical-align:middle make the item itself in middle according to the parent.

Upvotes: 2

Related Questions