问:
我有一个列表,并且我有一个用于其项目的点击处理程序:
foo
goo
如何将鼠标指针更改为手形指针(例如悬停在按钮上时)?现在,当我将鼠标悬停在列表项上时,指针变成了文本选择指针。
答1:
保持自己快人一步,享受全网独家提供的一站式外包任务、远程工作、创意产品订阅服务–huntsbot.com
正如人们所提到的,随着时间的推移,您现在可以安全地使用:
li { cursor: pointer; }
值得注意的是,对于 IE 5.5 以上的所有内容,只需执行 cursor: pointer 就足够了:quirksmode.org/css/cursor.html
有趣的是,指针!=光标和手!=指针,更加混乱。 :)
值得注意的是,quirksmode.org/css/user-interface/cursor.html#note(在前面的评论中引用过)指出手必须在 指针之后。我建议只使用指针 - IE 5.5 比 IE 6 更死。
@EdwardBlack 它曾经是不符合标准的奇怪浏览器所必需的,答案是很久以前更新的,以反映只是pointer这个问题已经超过 5 年的新方法。
的确。即使您在 IE5 兼容模式下运行 IE,cursor:pointer 仍然有效。因此,如果曾经有使用 cursor:hand 的借口,那么现在就没有了。
答2:
huntsbot.com – 高效赚钱,自由工作
用于 li:
li:hover {
cursor: pointer;
}
在运行代码片段选项后查看更多带有示例的游标属性:
https://i.stack.imgur.com/gJYJv.gif
.auto { 光标:自动; } .default { 光标:默认; } .none { 光标:无; } .context-menu { 光标:上下文菜单; } .help { 光标:帮助; } .pointer { 光标:指针; } .progress { 光标:进度; } .wait { 光标:等待; } .cell { 光标:单元格; } .crosshair { 光标:十字准线; } .text { 光标:文本; } .vertical-text { 光标:垂直文本; } .alias { 光标:别名; } .copy { 光标:复制; } .move { 光标:移动; } .no-drop { cursor: no-drop; } .not-allowed { 游标:不允许; } .all-scroll { 光标:全滚动; } .col-resize { 光标:col-resize; } .row-resize { 光标:行调整大小; } .n-resize { 光标:n-resize; } .e-resize { 光标:e-resize; } .s-resize { 光标:s-resize; } .w-resize { 光标:w-resize; } .ns-resize { 光标:ns-resize; } .ew-resize { 光标:ew-resize; } .ne-resize { 光标:ne-resize; } .nw-resize { 光标:nw-resize; } .se-resize { 光标:se-resize; } .sw-resize { 光标:sw-resize; } .nesw-resize { 光标:nesw-resize; } .nwse-resize { 光标:nwse-resize; } .cursors > div { 浮动:左; box-sizing:边框框;背景:#f2f2f2;边框:1px 实心#ccc;宽度:20%;填充:10px 2px;文本对齐:居中;空白:nowrap; &:nth-child(even) { 背景:#eee; } &:hover { opacity: 0.25 } } 光标示例 auto 默认 none context-menu 帮助 指针 进度 等待 单元格 < div class=“crosshair”>crosshair text vertical-text 别名 复制 移动 no-drop 不允许 all-scroll col-resize < div class=“row-resize”>行调整大小 n-resize s-resize e-resize w-resize ns-resize ew-resize ne-resize nw-resize se-调整大小 sw-resize nesw-resize nwse -调整大小
题外话,你用什么软件做了那个gif动画?等待..@Santosh Khalse
@fWd82 检查 ShareX - 录制 gif
我觉得这是对光标的有用提醒,并将代码添加为工具。这是上述代码的链接:spragucm.com/web-css-cursor-pointers
很棒的动画! @fWd82 - Peek 也适用于录制屏幕区域的 gif。 github.com/phw/peek
非常详细和很好的解释。
答3:
保持自己快人一步,享受全网独家提供的一站式外包任务、远程工作、创意产品订阅服务–huntsbot.com
您不需要 jQuery,只需使用以下 CSS 内容:
li {cursor: pointer}
瞧!便利。
便利?嗯...我知道你在那里做了什么,@denis-alpheus-cahuk
答4:
huntsbot.com洞察每一个产品背后的需求与收益,从而捕获灵感
利用:
li:hover {
cursor: pointer;
}
可以查看当前 HTML 规范的其他有效值(hand 是 not)here。
我不明白在这种情况下 :hover 伪类的用途是什么。当鼠标 not 悬停元素时,指定不同的光标有什么好处吗?我还读到 li:hover 在 IE6 中不起作用。
我想 :hover 只是为了具体,@Robert。我无法测试任何版本的 MSIE 的支持,抱歉,如果它不起作用,我不会感到惊讶! :P
为什么 hand 在最佳答案中,即使它不起作用?
@EdwardBlack cursor: hand 已弃用,不在 css 规范中。就像从ie5-6时代开始的。仅使用 pointer。
答5:
huntsbot.com高效搞钱,一站式跟进超10+任务平台外包需求
利用
cursor: pointer;
cursor: hand;
如果你想要一个跨浏览器的结果!
现在是 2018 年,跨浏览器开发不再需要 cursor:hand 了吧?
@Haramoz - 是的,cursor: hand 现在基本上已经过时了。自 IE 5.5 以来就没有出现过。
答6:
打造属于自己的副业,开启自由职业之旅,从huntsbot.com开始!
CSS:
.auto { cursor: auto; }
.default { cursor: default; }
.none { cursor: none; }
.context-menu { cursor: context-menu; }
.help { cursor: help; }
.pointer { cursor: pointer; }
.progress { cursor: progress; }
.wait { cursor: wait; }
.cell { cursor: cell; }
.crosshair { cursor: crosshair; }
.text { cursor: text; }
.vertical-text { cursor: vertical-text; }
.alias { cursor: alias; }
.copy { cursor: copy; }
.move { cursor: move; }
.no-drop { cursor: no-drop; }
.not-allowed { cursor: not-allowed; }
.all-scroll { cursor: all-scroll; }
.col-resize { cursor: col-resize; }
.row-resize { cursor: row-resize; }
.n-resize { cursor: n-resize; }
.e-resize { cursor: e-resize; }
.s-resize { cursor: s-resize; }
.w-resize { cursor: w-resize; }
.ns-resize { cursor: ns-resize; }
.ew-resize { cursor: ew-resize; }
.ne-resize { cursor: ne-resize; }
.nw-resize { cursor: nw-resize; }
.se-resize { cursor: se-resize; }
.sw-resize { cursor: sw-resize; }
.nesw-resize { cursor: nesw-resize; }
.nwse-resize { cursor: nwse-resize; }
您还可以将光标设置为图像:
.img-cur {
cursor: url(images/cursor.png), auto;
}
这不是问题的答案。
这可能不是问题的直接答案,但这是一个很好的指导方针。顺便谢谢!
答7:
huntsbot.com汇聚了国内外优秀的初创产品创意,可按收入、分类等筛选,希望这些产品与实践经验能给您带来灵感。
我认为仅在 JavaScript 可用时才显示手形/指针光标会很聪明。所以人们不会觉得他们可以点击不可点击的东西。
为此,您可以使用 JavaScript 库 jQuery 将 CSS 添加到元素中,如下所示
$("li").css({"cursor":"pointer"});
或者将其直接链接到点击处理程序。
或者当 modernizer 与 结合使用时,CSS 将如下所示:
.js li { cursor: pointer; }
答8:
huntsbot.com汇聚了国内外优秀的初创产品创意,可按收入、分类等筛选,希望这些产品与实践经验能给您带来灵感。
li:hover {cursor: hand; cursor: pointer;}
答9:
HuntsBot周刊–不定时分享成功产品案例,学习他们如何成功建立自己的副业–huntsbot.com
只是为了完整性:
cursor: -webkit-grab;
它还提供了帮助,即您在移动图像视图时所知道的。
如果您想使用 jQuery 和 mousedown emulate grab behavior,这将非常有用。
https://i.stack.imgur.com/y5uG4.gif
答10:
huntsbot.com聚合了超过10+全球外包任务平台的外包需求,寻找外包任务与机会变的简单与高效。
对于完整的跨浏览器,请使用:
cursor: pointer;
cursor: hand;
答11:
huntsbot.com – 程序员副业首选,一站式外包任务、远程工作、创意产品分享订阅平台。
为了能够使任何东西获得“鼠标更改”处理,您可以添加一个 CSS 类:
.mousechange:hover { 光标:指针; } 这里有一些文字
我不会说使用 cursor:hand,因为它仅适用于 Internet Explorer 5.5 及更低版本,并且 Internet Explorer 6 随 Windows XP (2002) 一起提供。当他们的浏览器停止为他们工作时,人们只会得到升级的提示。此外,在 Visual Studio 中,它将为该条目添加红色下划线。它告诉我:
验证 (CSS 3.0):“手”不是“光标”属性的有效值
HuntsBot周刊–不定时分享成功产品案例,学习他们如何成功建立自己的副业–huntsbot.com