How do I make an image relative to a specific element (i.e. a div block)?

Hey Webflow Community,

I am trying to have this big image as a background. However, I am struggling to align it to the right of my 1350 px container.

I have made a screenshot to illustrate what I am trying to achieve:

Thank you so much for your support!

Fred


Here is my site Read-Only: https://preview.webflow.com/preview/julian-being?utm_medium=preview_link&utm_source=designer&utm_content=julian-being&preview=6cbf4a8dffd1173f22aa9079a3acefae&workflow=preview
(how to share your site Read-Only link)

Hey @fredj32,

You’re pretty close, and it looks like you identified the problem when you red underlined what the image position is relative to: the section. To get it right aligned you need to have it relative to your 1350px container.

The issue is the 1350px container has a static position, and needs to have a relative position.

Once you set the 1305px container to relative you can right align your image to the edge of your 1350px container.

It’s just one of those weird positioning gotcha’s - if you look under the “positioning absolute” section of this documentation you will see the following:

position: absolute;

An element with position: absolute; is positioned relative to the nearest positioned ancestor (instead of positioned relative to the viewport, like fixed).

However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.

Note: A “positioned” element is one whose position is anything except static .

1 Like

Hi Andrew,
Thanks a lot. I would have spent hours trying to figure that out.
Works like a charm!

Best wishes and have a fantastic day!

Fred

1 Like