Answers for "How to place an image over another image in CSS"

1

how to place an image over another image in html

<!--Change the values of top and left to change the location of the images-->
<!--If you want to change which image is infront use z-index: (index number)-->
<!--The higher the z-index number will be displayed infront-->
<style>
.parent {
  position: relative;
  top: 0;
  left: 0;
}
.image1 {
  position: relative;
  top: 0;
  left: 0;
  border: 1px red solid;
  z-index: 2;
}
.image2 {
  position: absolute;
  top: 30px;
  left: 30px;
  border: 1px green solid;
  z-index: 1;
}
</style>
<body>
<div class="parent">
  <img class="image1" src="https://placehold.it/50" />
  <img class="image2" src="https://placehold.it/100" />
</div>
</body>
Posted by: Guest on March-09-2021
1

image on top of image css

.image1 {
  position: relative;
  top: 0;
  left: 0;
  border: 1px red solid;
}
.image2 {
  position: absolute;
  top: 30px;
  left: 30px;
  border: 1px green solid;
}
Posted by: Guest on September-14-2020

Code answers related to "How to place an image over another image in CSS"

Browse Popular Code Answers by Language