用于抓取光标(拖放)的 CSS
我有一个 JavaScript Web 应用程序,用户需要抓住背景来移动整个屏幕。所以我希望当它们悬停在背景上时光标发生变化。 -moz-grab
和 -moz-grabbing
CSS 光标非常适合此目的。当然,它们仅适用于 Firefox...其他浏览器是否有等效的光标?我是否需要做一些比标准 CSS 光标更自定义的事情?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果其他人偶然发现这个问题,这可能就是您正在寻找的:
In case anyone else stumbles across this question, this is probably what you were looking for:
我认为
move
可能是最接近的标准光标您正在做的事情的价值:I think
move
would probably be the closest standard cursor value for what you're doing:CSS3
抓取
和抓取 现在是
cursor
允许的值。为了提供跨浏览器兼容性的多种后备方案3 包括自定义光标文件,完整的解决方案如下所示:
更新2019-10-07:
CSS3
grab
andgrabbing
are now allowed values forcursor
.In order to provide several fallbacks for cross-browser compatibility3 including custom cursor files, a complete solution would look like this:
Update 2019-10-07:
比 CSS 光标“更自定义”意味着某种类型的插件,但您完全可以使用 CSS 指定自己的光标。我认为这个列表有你想要的:
来源:CSS 光标属性@ W3Schools
"more custom" than CSS cursors means a plugin of some type, but you can totally specify your own cursors using CSS. I think this list has what you want:
Source: CSS cursor Property @ W3Schools
我可能会迟到,但您可以尝试以下代码,该代码对我来说适用于拖放。
您可以在上面的 URL 中使用下面的图像。确保它是 PNG 透明图像。如果没有,请从谷歌下载一个。
I may be late, but you can try the following code, which worked for me for Drag and Drop.
You can use the images below in the URL above. Make sure it is a PNG transparent image. If not, download one from google.
您可以创建自己的光标并使用
cursor: url('path-to-your-cursor');
将它们设置为光标,或者找到 Firefox 的光标并复制它们(好处:外观一致每个浏览器)。You can create your own cursors and set them as the cursor using
cursor: url('path-to-your-cursor');
, or find Firefox's and copy them (bonus: a nice consistent look in every browser).闭合的手形光标不是 16x16。如果您需要相同尺寸的它们,这里您可以将它们都设置为 16x16 px
或者,如果您需要原始光标:
https://www .google.com/intl/en_ALL/mapfiles/openhand.cur
https://www.google.com/intl/en_ALL/mapfiles/closehand。当前
The closed hand cursor is not 16x16. If you would need them in the same dimensions, here you have both of them in 16x16 px
Or if you need original cursors:
https://www.google.com/intl/en_ALL/mapfiles/openhand.cur
https://www.google.com/intl/en_ALL/mapfiles/closedhand.cur