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!
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 trial

Chun Hsiang Huang
5,787 PointsPin an image onto another image (HTML/CSS)
Hi, does anybody know how to pin an image on to another image, and keep their relative position the same no matter how big the screen is (responsive)?
1 Answer

james south
Front End Web Development Techdegree Graduate 33,271 PointsYou could set the back image position: relative
and the front image position: absolute
, then use the top/bottom/left/right
properties on the front image to put it anywhere relative to the back image, like 5%
from the top
.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsThe front image isn't going to be a child of the back image so the absolute positioning will not be relative to the back image. I think this could work out if the 2 images had the same parent and the absolute positioning was done relative to this parent.
Chun Hsiang Huang
5,787 PointsChun Hsiang Huang
5,787 PointsJames and Jason thank you so much! I give the parent div a position: relative, and the other pictures in side the div position: absolute, and it works!