I have a list of images in an html table and need to overlap a small icon on each image. How can we do this using z index and positioning?
We're applying a negative right margin on a floated left element that allows content to overlap. -100% is equal to the width of the container so it shifts the image to the left and allows the bottom image to render beneath it as if it's not in the DOM. Codepen here: HTML.
Background blend mode with two images It's as easy as adding two background images in the CSS declaration. The next choice is to have a background color (or not). If you do not want a background color, this can be removed and the images will blend together depending on the blend mode that you choose.
You can easily put a photo on top of another photo using Fotor, a free online photo editor. Simply drag and drop the image you want to overlay into Fotor- this will become your background picture. Then add a new image over it. You can adjust the transparency levels to blend two images together perfectly.
.under {
position: absolute;
left: 0px;
top: 0px;
z-index: -1;
}
.over {
position: absolute;
left: 40px;
top: 10px;
z-index: -1;
}
<img src="https://tafttest.com/184x46.png" width="184" height="46" class="under" />
<img src="https://tafttest.com/100x84.png" width="100" height="84" class="over" />
The element you want to be on top needs to have a higher z-index
So the small icon would have a z-index of 2 and the images would have a z-index of 1
Example:
.icon {
z-index: 2;
position: relative;
left: 30px;
top: 30px;
}
.images {
z-index: 1;
}
You could use position:relative
and set right:30px
, bottom:30px
, that would shift it up and left by 30 pixels.
CSS:
.icon{
position:relative;
right:30px;
bottom:30px;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With