The vertical-align property has two prerequisites for use:
- The items you are trying to vertically align must be siblings.
- The elements you are trying to align vertically should not be block level elements.
This, as they say, is actually quite easy to solve:
<div id="widgetWhite"> <div id="widgetWhiteIcon"> <a href="#" title="White"><img src="http://placehold.it/100x100" alt="White Icon" /></a> </div><div id="widgetWhiteContent"> <p>I would love it if this worked.</p> <a href="#">Download PDF</a> </div> </div>
Note that the closing div for #widgetWhiteIcon and the opening division for #widgetWhiteContent relate to: </div><div id="widgetWhiteContent"> . This allows you to control the distance between these two elements, since usually any space between inline elements in your layout is displayed in the presentation.
Edit: You can equally set font-size: 0 to #widgetWhite without worrying about the space. font-size inherited in child elements, so you will need to explicitly set this after, for example: #widgetWhite { font-size: 0; } #widgetWhite * { font-size: 12px; } #widgetWhite { font-size: 0; } #widgetWhite * { font-size: 12px; }
CSS
p { margin: 0; } #widgetWhite > div { vertical-align: middle; display: inline-block; } #widgetWhiteContent { margin: 0 0 0 4px; } #widgetWhiteContent a { margin: 1em 0 0; display: block; }
Preview: http://jsfiddle.net/Wexcode/DcWB8/
source share