Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    CSS Position Absolute in DIV container

    Hello,

    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:

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

    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?

    Thanks

  • #2
    Regular Coder
    Join Date
    Jan 2009
    Posts
    173
    Thanks
    5
    Thanked 12 Times in 11 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    May 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jan 2009
    Posts
    173
    Thanks
    5
    Thanked 12 Times in 11 Posts
    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.
    Last edited by nikee; 05-18-2010 at 01:50 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •