:active css selector not working for IE8 and IE9

后端 未结 2 711
难免孤独
难免孤独 2020-11-28 15:08

Here\'s my site. This is the last problem of a series of cross-browser discrepancies I\'ve experienced and solved thanks to the community.

Basically, in Internet Exp

2条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 15:24

    Just for the sake of relevancy and to save anyone else the hassle of searching for a solution, I also found a "bug" in IE <= 10, where you cannot apply styles to an :active child, e.g;

    a:active img {
        position:absolute;
        top:-30px;
    }
    

    The above won't change the position of the image in IE <= 10, in which case you would need to apply :active on the child element itself;

    a:active img,
    a img:active {
        position:absolute;
        top:-30px;
    }
    

    Which in most cases isn't a perfect solution as any text inside the anchor needs to have a higher z-index value than the image, meaning that the image will only change it's position based on clicking the image itself (giving the image the :active state)... which left me in a minor bind, but a bind none-the-less (for a css only solution).

    So although this is not a fix, it is more of a note of "warning" for others about the downfall to the :active pseudo selector in IE. Rubbish. =(

提交回复
热议问题