I want to generate multiple divs in a specified area. I want to load the relative positions to the parent of these divs out of a database.
So for example:
- div 1 – 250px, 100px
- div 2 – 400px, 800px
- div 3 – 50px, 85px
As you can see the problem here is that these divs aren’t loaded in order of their relative location. Also there will be overlapping divs.
How would I go about placing these in the correct relative position to the parent.
I load these locations out of a MySQL database with PHP, they each have an id and the locations. I want to put all the divs in one parent div.
I tried using both relative and absolute position in CSS but they didn’t get me the desired result.
Make the parent have a position of relative or absolute. Then give all children position ‘absolute’ with a left and top which come from the database.
HTML:
CSS:
Fiddle here: http://jsfiddle.net/xgG2C/