how to place an image over another image in html

Solutions on MaxInterview for how to place an image over another image in html by the best coders in the world

showing results for - "how to place an image over another image in html"
Brandi
25 Sep 2017
1<!--Change the values of top and left to change the location of the images-->
2<!--If you want to change which image is infront use z-index: (index number)-->
3<!--The higher the z-index number will be displayed infront-->
4<style>
5.parent {
6  position: relative;
7  top: 0;
8  left: 0;
9}
10.image1 {
11  position: relative;
12  top: 0;
13  left: 0;
14  border: 1px red solid;
15  z-index: 2;
16}
17.image2 {
18  position: absolute;
19  top: 30px;
20  left: 30px;
21  border: 1px green solid;
22  z-index: 1;
23}
24</style>
25<body>
26<div class="parent">
27  <img class="image1" src="https://placehold.it/50" />
28  <img class="image2" src="https://placehold.it/100" />
29</div>
30</body>
31