如果我为一个普通的 div 使用一个类,我可以这样写 css 吗:
.messagebc:hover {
...
}
合法吗?
最佳答案
在非链接元素上使用 :hover 是低效的。
避免为 IE 客户端的非链接元素使用 :hover 伪选择器。
If you use :hover on non-anchor elements, test the page in IE7 and IE8 to be sure your page is usable. If you find that :hover is causing performance issues, consider conditionally using a JavaScript onmouseover event handler for IE clients.
:悬停非链接元素的伪选择器是一个非常低效的选择器(例如): 例如:
h3:hover {...}
.foo:hover {...}
#foo:hover {...}
div.faa :hover {...}
众所周知,非 anchor 元素上的 :hover 伪选择器在某些情况下会使 IE7 和 IE8 变慢*。当不使用严格的文档类型时,IE7 和 IE8 将忽略 :hover 在除 anchor 之外的任何元素上。当使用严格的文档类型时,:hover 在非 anchor 上可能会导致性能下降。
关于html - css:每个类都支持:悬停状态吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4204527/