Search code examples
htmlcssdictionaryarea

Place div at specific coordinates using something like the coords attribute of a map area


Is there a way I could place a div on top of a certain spot in an image? Say I have the coordinates of that spot that would be used in an HTML map area, what would I need to do to reuse those coordinates for placing that div?


Solution

  • I guess you could wrap your image in a div, and set that div's position to relative then you can place inner div to absolute

    <div class="relative">
    <img your map/>
    <div class="pin"><img your pin image></div>
    </div>
    
    .relative{
    position:relative
    }
    .pin{
    position:absolute;
    top:20px;
    left:50px;
    }
    

    Of course you would set top and left via javascript as needed