3

我对 CSS 伪类 :focus 或 :active 很困惑,因为它适用于 :hover 在 ie8 中,但不适用于 :focus 或 :active。像这样:

<!doctype html>
<head>
<style>
#target{ display:block; width:1em; height:1em; background:lightgreen; }
a[href="#target"]:focus~#target{ width:10em; height:10em;  }
</style>
</head>
<body>
<a href="#target">target</a>
<div id="target" ></div>
</body>
</html>

当我使用 :active 替换 :focus 时,发生了同样的问题,但是 :hover 效果很好~当我使用 :focus 或 :active 没有 ~ 时,它也很好用。好糊涂~TX~

4

1 回答 1

0

:focus 仅在您使用 tab 键获取所需链接时才会发生。:active 的标签相当于 onmousedown。

于 2011-12-27T16:20:21.770 回答