IE 7/8: Active Pseudo on Block Elements

2019-09-17 09:49发布

i have run into problem regarding IE7/8 ignoring the :active pseudo class on elements with display:block;

HTML:

<a>My Link</a>

CSS That Works:

a:active{color:yellow}

CSS That Fails:

a{display:block}
a:active{color:yellow}

Does anyone know of a solution to this, or will I have to resort to JS?

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-17 10:23

Ironically, @Kevin already "fixed" your problem without even realising.

Change the HTML from this:

<a>My Link</a>

to this:

<a href="#">My Link</a>

and it works in IE7, see: http://jsbin.com/exuga3

Unexpected things like this can happen when you have <a> tags without an href attribute.

If you really don't want the "hand mouse pointer", specify cursor: default: http://jsbin.com/exuga3/4

查看更多
登录 后发表回答