Picture: https://i.sstatic.net/KFNR1.png I am working on a design with a yellow container div that I want to keep at 50% width of the window. Inside this container is a purple image div that stretches to 100% of the parent container's width, and there is a pink sticky label positioned on top of the image div (positioned absolutely so it can be offset relative to the image). I want to keep this entire half of the screen in fixed positioning so it stays sticky as I scroll.
There is also a title under the image that needs to be visible regardless of vertical window resizing. In this case, the image div should shrink vertically if necessary to ensure the title remains visible.
In essence, I aim to have the image div always be 100% width of the parent container div, with the ability for the image div to shrink vertically based on a max percentage height. Alternatively, I would like to maintain a fixed aspect ratio (3:4 or similar) when the image shrinks vertically.
I am trying to avoid using fixed pixels or ems in my CSS overall since the website needs to stretch fluidly vertically to accommodate the title under the image.
The HTML structure looks something like:
<wrapper>
<left-column>
<normal text and scrollable content>
<right-column-yellow>
<image with sticky pink label>
<purple image div>
<image title>
Apologies if this seems confusing; my brain is quite fried! Can anyone please assist me with this?