SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Div over an Image ?

    How can I change the position of DIV over an image ?

  2. #2
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One way is to add position: relative; to your image and then abosolute position the div according to it.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2007
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fredda View Post
    One way is to add position: relative; to your image and then abosolute position the div according to it.
    can u plz help with a sample code ?

  4. #4
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <img src="someimage.png" alt="alternative text" style="position: relative;" /><span style="position: absolute; top: 50px; left: 50px;">Some text..</span>

  5. #5
    SitePoint Wizard bronze trophy Centauri's Avatar
    Join Date
    May 2007
    Location
    Newcastle, Australia
    Posts
    3,718
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by fredda View Post
    One way is to add position: relative; to your image and then abosolute position the div according to it.
    That won't work as the div is not inside the image. Absolute positioning is relative to the nearest positioned parent.

    Why not have the image as a background to the div?

  6. #6
    SitePoint Member
    Join Date
    Oct 2004
    Location
    Aldershot, Hampshire, UK
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if this applies; I needed a div to appear over a web page to 'ghost' down the background and then have another centred within this that contained the 'pop-over' content (see CRF printing and click the Callback link), is this similar to what you are trying to achieve?

  7. #7
    SitePoint Mentor bronze trophy
    John_Betong's Avatar
    Join Date
    Aug 2005
    Location
    City of Angels
    Posts
    1,836
    Mentioned
    73 Post(s)
    Tagged
    6 Thread(s)
    Hi priyakochin,

    >>> How can I change the position of DIV over an image ?

    Can you explain what you want without using terms such as DIV and image.

    There may be alternative solutions of what you want positioned on the webpage.
    Learn how to be ready for The New Move to Discourse

    How to make Make Money Now with a *NEW* look

    Be sure to congratulate Patche on earning Member of the Month for July 2014

  8. #8
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Centauri View Post
    That won't work as the div is not inside the image. Absolute positioning is relative to the nearest positioned parent.
    Ah okay, my bad


Bookmarks

Posting Permissions

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