Overlay 2 images
Position relative to container and absolute in images:
All of the above answers are missing the fact that you need to place the parent with something other than static, or else you place them in an absolute browser window, which I suppose you don't want to do.
position: absolute
will give your position in the container of the nearest parent with some positioning. Thus, we give the parent position:relative;
without a top or bottom declaration, so it will be 0px off where it would normally be (i.e. no change but still has it position
declared).
<div id="container">
<img src="data:image/png;base64,R0lGODlhAQABAPAAAC+byy+byywAAAAAAQABAEAIBAABBAQAOw==" style="height:125px; width:125px;">
<img class="hide" src="data:image/png;base64,R0lGODlhAQABAPAAADCQIzCQIywAAAAAAQABAEAIBAABBAQAOw==" style="height:125px; width:125px;">
</div>
#container{
position:relative;
}
#container img{
position:absolute;
top:0;
left:0;
}
.hide:hover{
opacity:0;
}
Edit: Added your hidden functionality
source to share
If you set an absolute position, you can control where you want to place it.
<style>
#overlay{position:absolute; top:0px;}
</style>
<div id="layer1"><img src="img1.png"></div>
<div id="overlay"><img src="overlay_image.png"></div>
Now you need to place the #overlay where you want by setting the top and left positions, i.e. top: 0px, left: 300px;
source to share