应该在带有或不带有:hover伪类的规则中设置cursor属性吗? [英] Should the cursor property be set in a rule with or without the :hover pseudo-class?

查看:189
本文介绍了应该在带有或不带有:hover伪类的规则中设置cursor属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说你还是我已经编码了一个HTML元素...

Say you, or I, have coded an HTML element...

<a id='hydrogen' href='#'>H</a>

...和一些:hover CSS ...

...and some :hover CSS...

#hydrogen:hover {
  background:red;
}

...现在,我们想在悬停时放置一个精美的手形光标.有两种选择:

...and now we want to put a fancy hand cursor when hovering. There's two options for this:

应用于无状态元素:

#hydrogen { 
  cursor:pointer;
}

或应用于:hover状态.

or, apply to :hover state.

#hydrogen:hover { 
  color:red;
  cursor:pointer;
}

我的问题:有什么理由为什么一种方法比另一种方法具有决定性的优势?

My question: is there any reason(s) why one way is decisively better than the other?

...还是番茄,番茄?

...or is it tomato, tomato?

推荐答案

兼容性:IE6和更低版本仅识别a元素上的:hover伪类.

Compatibility: IE6 and below only recognize the :hover pseudo class on a elements.

这篇关于应该在带有或不带有:hover伪类的规则中设置cursor属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆