I am a HTML/CSS newbie and vertical aligning of elements in side div is driving me crazy. Basically, I have a div
that contain a mix of text and images and all I wanted to do is vertically align the elements in the middle of th ediv.
According to this post:
Inline elements (and only inline elements) can be vertically aligned in their context via vertical-align: middle. However, the “context” isn’t the whole parent container height, it’s the height of the text line they’re in.
So, I create a SPAN
and event set the diplay: inline
but nothing works:
<div id="main_section" class="main_align" >
<span class="inline">
<span class="inline"><img src="http://placehold.it/50x50" /></span>
<span class="small inline">A Very Small Text</span>
<span class="medium inline">Medium String</span>
</span>
</div>
Here is the jsfiddle.
Any pointers will be greatly appreciated.
Note: I am happy if this works in Chrome and Firefox. No need to address IE specific issues.