I am making a website where by clicking on a next button, the browser requests a new image URL from the server and loads the image using jQuery. I want to show the loading image on top of the old image when the request happened (like Facebook).
HTML
<div1>
<img id="rel" src="http://localhost/images/original.jpg" height="400" width="500"></img>
<div2>
<img id="rel" src="http://localhost/images/loading.jpg" height="40" width="50"></img>
</div2>
</div1>
CSS
div1
{
position:relative;
}
div2
{
position:absolute;
top:50%;
left:50%;
}
When I try this in jsFiddle the image does not appear over the other image. I only know basic CSS. Forgive any blunders in the above code.
CSS:
There was some errors with your code:
You should not have two same ID
relYou must put both images in the same Parent Div, give it a
position:relative;so that the second image is considered absolute to this Parent Div, not to the whole page.Check this http://jsfiddle.net/Kfxha/
To Position the second image right at the center, you must make some math calculations.