When an image is scaled to percentage proportions, it retains its aspect ratio (if done correctly). I need a div
to emulate this behavior.
My situation is that I need to accurately position an element in relation to an image. The image is sized to 100% of the browser width, and a variable height. I want to use pixel measurements to size and place a div exactly 800 pixels from the edge of the image, but using the image's pixels as the measurement (not the browser pixels). Is there a way to do this?
It is possible to calculate the horizontal position in percents, but vertical percentages won't work in my case.
I could use Javascript/JQuery or SASS, and those answers are welcome, but I'd prefer a pure-CSS solution.
If it doesn't make sense, here's a jsfiddle with more information: https://jsfiddle.net/ckcmrs1g/1/