Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMark Libario
9,003 PointsHelp with overlapping images..
Hey guys..
I want two same images to overlap each other like 2 tiles a little bit spread apart (bottom,right)
I tied z-index and positionings but the two image just displays as block level.. Heres the CSS
.protein1 {
position: relative;
margin-left: auto;
margin-right: auto;
top: 0;
left: 0;
z-index: 1;
}
.protein2 {
position: absolute;
margin-left: auto;
margin-right: auto;
top: 250px;
left: 350px;
z-index: -1;
}
Heres the HTML:
<div class="container">
<div class="protein1">
<img src="img/protein1.jpg" width= 400px height= 550px class="rounded img-fluid">
</div>
<div class="protein2">
<img src="img/protein1.jpg" width= 400px height= 550px class="rounded img-fluid">
</div>
</div>
I changed the image size directly because its too big, is there anyway I can change it ?
The style I wanted to do was that these two overlapping images are floated on the right side while the "text descriptions" are wrapping around it from the left.
1 Answer
Kalib Watson
13,542 PointsYour images are probably displaying as block level because they are wrapped in divs. Divs are block level elements, and images are inline elements. If you can, I'd suggest taking away the wrapper divs around your images so that they can be inline with one another, and therefore overlap.
If you can't remove the divs for some reason, try adding display: inline to their styles and see if that helps.