Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,258 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!