0

In other browsers this works, only in IE8 it does not from the ones I tried. In later Browser of internet explorer it works fine.

I have the following code:

CSS:

.imgcontainer {
  display: block;
  margin: 0 auto;
  width: 100px;
  height: 100px;
}

.imgcontainer img {
  width: 75px;
  height: 30px;
}

HTML:

<ul>
  <li>
    <a href="http://somelink.com">
      <div class="imgcontainer">
        <img src="img/someimage.png">
      </div>
    </a>
  </li>
</ul>

What happens is the following: Anywhere around the image the link works, but as soon as I click on the image, the link does not respond. It is like the image is placed on top of the link.

Thanks in advance for your help

Serge Inácio
  • 1,366
  • 9
  • 22

1 Answers1

0

I've had the same issue recently and my solution was to bring the link inside the div and specify the width and height of it:

.imgcontainer {
display: block;
position:relative;
margin: 0 auto;
width: 100px;
height: 100px;
}

.imgcontainer a{
position:absolute;
top:0;
left:0;
width:100px;
height:100px;
}

.imgcontainer img {
width: 75px;
height: 30px;
}


<ul>
 <li>
    <div class="imgcontainer">
      <a href="http://somelink.com">
       <img src="img/someimage.png">
      </a>
     </div>
 </li>
</ul>

This may not be the best solution but it has worked for me.

Alex Turner
  • 148
  • 10
  • Thank you for your answer :). But in my case this would not work as the image would expand, and I would like to keep the size I set for the image. – Serge Inácio Dec 03 '14 at 12:20