1

I have a three year old website, which has been perfectly functioning, until now. The new version of the Google Chrome browser, v.41, experiences a strange bug: I have an IMG tag inside of an A tag, and when I click on it, the image randomly changes position instead of going to the where the link is linked. This only occurs with the latest Chrome, v.41. Older versions of Google Chrome and other browsers do not experience this problem. I have tried this on both Windows 7 and OSX 10.10

I copied the code to jsfiddle in case you want to look at it. I have not used any outdated CSS functions and there is no JavaScript used at all.

The linked image's code:

<a class="insImg" href="#">
    <img class="imapa-foto" src="http://www.dolejsialej.cz/photo/thumbs/RD2-mars.jpg" />
    Dům 1
</a>

I would just like to know whether there is something wrong, or if it is just this version of Google Chrome.

Matthew J.
  • 91
  • 4
Vaca
  • 35
  • 5

1 Answers1

1

As you've mentioned it looks to be a bug with Chrome.

I've played with the code a bit and this part seems to have been part of the issue:

ul li img {
    width: 150px;
    position: absolute;
    top: 0;
    left: 0;
}

I don't understand why clicking on the anchor causes this positioning to be dropped, but as a quick workaround you can just move the positioning into the anchor like so:

ul li a {
    text-decoration: none;
    -moz-opacity: 1;
    opacity: 1;
    color: #fff;
    position: absolute;
    top: 0;
    left: 0;
}
ul li img {
    width: 150px;
}

See the updated fiddle below.

https://jsfiddle.net/2d4b1mLm/5/

rlemon
  • 17,518
  • 14
  • 92
  • 123
  • Simply making the `a` elements `display:block` seems to fix the issue as well, https://jsfiddle.net/2d4b1mLm/6/ – CBroe Mar 23 '15 at 16:56
  • 1
    seems to be related to this: http://stackoverflow.com/questions/23642290/ie-offsetting-and-ignoring-height-width-of-anchor-focus-outlines/23644188#23644188 -- https://jsfiddle.net/2d4b1mLm/7/ once the focus is lost the element jumps. – rlemon Mar 23 '15 at 17:01
  • Thanks a lot for the workarounds, both are working ;) still it's strange bug – Vaca Mar 23 '15 at 17:03
  • @rlemon: That explanation seems to make sense, although curios why OP would only see this behavior emerging now then … anyway, fix(es) found, so all’s well :-) – CBroe Mar 23 '15 at 17:05