View Full Version : CSS Position Absolute in DIV container

May 17th, 2010, 10:03 PM

I want to place a picture on a html site with a position relative to the body.

The problem is, that my picture is located inside a DIV tag and I cannot change that div tag at all, I don't have access to it (it is in a template).
Now if I place my picture with:

<img src="ixxximage.jpg" style="position:absolute; left:350px; top:500px; z-index:1000;">

then the position of the picture is always relative to the parent DIV tag, which is the standard and correct.
Now, is there any way to override that and make the position of the picture relative to the entire window page, meaning that "position:absolute; left:0px; top:0px;" would place the picture in the top left corner of the site?


May 17th, 2010, 10:22 PM
If i'm not wrong, the reason it's relative to the parent DIV tag is because it has been set to be positioned relatively with CSS. By default, it's set to Static.

May 18th, 2010, 01:13 PM
Yes, but is there a way around that? I need to position the picture relative to the body and not to the DIV. But I cannot change the DIV and cannot take the picture out of the DIV.

May 18th, 2010, 02:46 PM
Not that i know of. You'd have to place the picture outside of the DIV, preferably right after the BODY tag.

What kind of template are you working on?

EDIT: You could throw some Javascript in there that rips out the image and stiches it in right after the body starts, but i'm not familiar with Java so you should really ask someone else about that. And i don't recommend doing it either as not all of the users have Javascript turned on.