Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何使用 Modernizr 在 IE7/8(不支持这些属性)中测试和设置 input:focus 和 input:active 的样式?
还是我应该只使用基本的 JS/CSS 来做到这一点?什么是这样做的好方法?
这是 Modernizr 之外的一个解决方案,但它的工作方式非常相似(通过向 DOM 添加一个元素,为其:hover状态设置样式,然后测试该状态是否已发生)。
:hover
对 James Padolsey 的这篇文章表示敬意。
您可能需要检查活动状态以外的其他事件mousedown,mouseup但这似乎适用于现代浏览器(维护本机:focus和:active状态)以及 IE7(带有假.focus和.active类)。
mousedown
mouseup
:focus
:active
.focus
.active
小提琴