Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: not2easy
The problem is I have an image, in a DIV, that I need to overlay on top of the page. The problem I'm having is that when I resize the browser window - that image stays in the same place and does not move with the rest of the site. I've tried positioning that div within other divs and changing the position from absolute to relative etc but it still seems to remain static on the page.
Here's the DIV code for the overlaying image:
I'm sure it's something very, very simply but I'm just not sure what?! Any help would be very much appreciated.
margin-top: -29px; /* half of the height */
margin-left: -274px; /* half of the width */
Basically it first move e.g. the left side to the middle (
) and then moves it back for half of the width of the element (negative margin).
If you want to center it relative to a parent, make sure the parent has position. Position can be given by e.g. "
" without needing to "nudge" it itself using left/top/right/bottom.