Daft Daft - 1 year ago 73
CSS Question

Center text next to image in dynamically created div. jQuery

At the moment, the text is aligned with the top of the image. Is there any way for me to pad the text down so it is aligned with the center of the image?

Any padding I add to ui-title moves the entire div.

Or would I have to restructure the jQuery to achieve this?

$('<img class="confirm" src="image.png" alt="" height="30" width="30"></img>')

Answer Source

First off like the first comment says, there is no need for </img>. img tags can be self closing so you can change it to <img class="confirm" src="image.png" alt="" height="30" width="30" />.

Your looking to use vertical-align: middle; but you need to make sure the div containing your text is set to display: inline; or display: inline-block;.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download