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 trial

CSS

Chun Hsiang Huang
Chun Hsiang Huang
5,787 Points

Pin 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
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

You 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.

The 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
Chun Hsiang Huang
5,787 Points

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