How to create link inside div with absolute position?

Discussion in 'HTML & Website Design' started by computerzworld, Oct 8, 2010.

  1. #1
    Hello,
    I want to create link with images inside div having absolute position. But link is not being generated. How can I apply link to that div? here is my code.

    <div style="position: absolute;padding-top:100px;padding-left:50px;">
    <a href="http://www.example.com"><img src='path-to-image'></a>
    </div>
    
    Code (markup):
    Please help me.

    Thanks in advance.
     
    computerzworld, Oct 8, 2010 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    :confused: What browser are you using? It works fine in Firefox, IE8, Chrome, Opera, and Safari.
    It would help if we could see the rest of the page markup.
     
    Cash Nebula, Oct 8, 2010 IP
  3. anupviews

    anupviews Member

    Messages:
    795
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    35
    #3
    Try this:

    <div style="position: absolute;top:100px;left:50px;">
    <a href="http://www.example.com"><img src='path-to-image'></a>
    </div>
     
    anupviews, Oct 8, 2010 IP
  4. ggo4th

    ggo4th Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You are applying the link to the image. I agree with Cash. We would really need to see the rest of the markup in order to help.
     
    ggo4th, Oct 8, 2010 IP
  5. syedmuktha

    syedmuktha Peon

    Messages:
    64
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Try what HackTweaks say. But, check it out browser compatibility..
     
    syedmuktha, Oct 8, 2010 IP
  6. HackTweaks

    HackTweaks Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Sorry, here is the reply:
    Remove padding add top and left position instead.

    Here is the code:

    <div style="position: absolute;top:100px;left:50px;">
    <a href="http://www.example.com"><img src='path-to-image'></a>
    </div>

    Also make sure that you don't have position:relative defined in any of the outer wraper. Other wise you'll have to set the value of top and left according to the position of the wrapper.

    Hope this helps.
     
    HackTweaks, Oct 11, 2010 IP