I want to position four divs relative to another. I have a rectangle div, and I want to insert 4 divs at its corners. I know that CSS has an attribute "position:relative", but this is relative to the normal position of that element. I want to position my divs not relative to their normal position, but relative to another element (the rectangle). What should I do?
I want to position four div s relative to another. I have a rectangle
Share
position: absolutewill position the element by coordinates, relative to the closest positioned ancestor, i.e. the closest parent which isn’tposition: static.Have your four divs nested inside the target div, give the target div
position: relative, and useposition: absoluteon the others.Structure your HTML similar to this:
And this CSS should work: