Image over Image CSS

css, html, image

Solution

Each element in a page has a particular stacking order. If you do not set them explicitly then it will be stacked in accordance to the order in DOM.

You can control the stacking order by setting the property

z-Index

The higher the z-index value goes the higher will be the stacking order for the element.

If you can set the gif image as the background of a cell then

background-image

property will be the best one. First set the gif image as a background to the cell and place the png button in the cell and position it inside the cell.

Problem

I am creating a webpage and I am trying to put a png (buttons) over gif files. When the page renders, it makes the png file appear after or under the gif file. I tried using and tags but neither work. I have also tried using various CSS padding, alignments etc. but it doesn't seem to work. Is there a way (code) to get images to appear on top of images?

Original source