This question already has an answer here:
I want to create image box(with image).
It's ugly when text is in the top of box.
How can I align text to middle?
I tried to use vertical-align
, but it seems, that it don't works
EDIT:
Your solution works fine with short messages.
But if they will be multi-lined, it is ugly again.
Is it possible to not increase size of line If we don't need it?
If you want to middle align a block with multiple lines, you can use
display:inline-block
around that block. So if you have:with
add
See http://jsfiddle.net/yNpRE/1/ and http://jsfiddle.net/yNpRE/
Be warned though, that while this works in modern browsers, it doesn't work with IE7 or earlier.
Set the
line-height
to theheight
of thediv
.So
Working example: http://jsfiddle.net/jasongennaro/DhHnZ/1/
What usually works fine is
line-height
:http://jsfiddle.net/DhHnZ/2/