You can use this plugin do your work:
jQuery.fn.verticalAlign = function ()
{
return this
.css("margin-top",($(this).parent().height() - $(this).height())/2 + 'px' )
};
Then you can use it like:
$("#mydiv").verticalAlign()
For your code:
<div style="height:240px;width:100%;">
<div id="mydiv" style="width:33%;height:100px">
<span class="" style="font-size:26px">Hello </span>
<br/><br/>
<img style="width:150px" src="example.jpeg"
/>
</div>
</div>
Just add the following:
$("#mydiv").verticalAlign()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…