I'm trying to get the text to be on the right side and vertically center aligned with the image. How can I do that?
My current code:
<div style="display: table;">
<div style="display: table-cell;"><img src="//dummyimage.com/100"></div>
<div style="display: table-cell;">text</div>
</div>
In table cell, the default value of
vertical-align
isbaseline
. You can change that tomiddle
for center align. Read more about it on MDN.use CSS3 Flexible Box Layout:
from the documentation:
your example with centered text to the right would look like this
I found this cheat-sheet very helpful and browser compatibility you find here
Use td, tr and table.
See JsFiddle for example: https://jsfiddle.net/bndr6x4y/1/