How do i position this hotspot element to be (0,0) at top left relative to the image whilst maintaining it in the centre of the container?
Ive tried several things but it keeps being positioned relative to the container because the image is displayed as block to be centered. But I want the button to be relative to the image not the blocked image..
--Update--
I can make it position correctly if i unblock the image but this uncenters it.
HTML
<div class= "img-container">
<img id ="img" src = "resources/images/androg.front.jpg">
<button id="hotspot-button" class="btn btn-fab"></button>
</img>
</div>
CSS
.img-container{
position: relative;
display: block;
height: 100%;
vertical-align: middle !important;
margin-left: auto;
margin-right: auto;
}
#img {
height: 100%;
//position: float;
position: relative;
display: block;
vertical-align: middle !important;
margin-left: auto;
margin-right: auto;
}
#hotspot-button {
position:absolute;
top:0%;
left:0%;
}
You are almost there. All you need to do is update your .img-container
to include this:
.img-container{
display: table;
}
This will position the #hotspot-button
over the top of the image with the coordinates 0,0 from the top, left.
Here is the link to the JSFiddle.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments