Let me start from the illustration which presents the outcome I want to achieve: http://jsfiddle.net/2DvF6/1/
<div id="controler">
<img id="i1" src="arrow1.png">
<img id="i2" src="arrow1.png">
</div>
img{
width:100%;
}
#i1{
visibility:hidden;
}
#i2{
position:absolute;
top:-50%;
left:0px;
}
#controler{
position:absolute;
width:100px;
}
Assume I control only the width of the div#controler and I do not know (and do not want to know) what are the dimensions of the image. I use the nice feature of the img tag, that if height is unspecified then the aspect ratio is used to compute it. Now, how can I move the image -50% of its height up, as in the example? I tried position:relative + top:-50% but it did nothing good. The "solution" I presented requires me to put two images, one invisible to force the size of the div, and one which can then use top:-50%. I've tried vertical-align:middle but it did not help.