Wednesday, 21 August 2013

Is it possible to keep the absolute positions of elements as the parent div grows and shrinks in size?

Is it possible to keep the absolute positions of elements as the parent
div grows and shrinks in size?

I have a bunch of hotspots inside a div and their absolute top and left
pixels are stored in a database because there is a drag and drop interface
that allows them to be re-positioned and saved.
This is dumped into a responsive grid and so the parent div can resize
with the browser. The div has a background image that has a native
resolution of 650 x 900. At the moment I am using this simple calculation.
top:(decimal)hover.YOff/650)*100); left:(decimal)hover.XOff/900)*100);
I am also using "background-size: cover;" to get the image to stretch.
The problem is that they are moving around way too much on resizing. Is
there a better way to do this?

No comments:

Post a Comment