简体   繁体   English

CSS 自定义 cursor 在 FF/Chrome 中不起作用

[英]CSS custom cursor doesn't work in FF/Chrome

I am trying to create a custom cursor using the following image:我正在尝试使用下图创建自定义 cursor:

http://anuary.com/dev/hp/pad3/public/images/hand-cursor.png

The image size must be retained.必须保留图像大小。 I've tried simply to use body { cursor: url('http://anuary.com/dev/hp/pad3/public/images/hand-cursor.png'); }我试过简单地使用body { cursor: url('http://anuary.com/dev/hp/pad3/public/images/hand-cursor.png'); } body { cursor: url('http://anuary.com/dev/hp/pad3/public/images/hand-cursor.png'); } , though that doesn't work in FF/Chrome. body { cursor: url('http://anuary.com/dev/hp/pad3/public/images/hand-cursor.png'); } ,尽管这在 FF/Chrome 中不起作用。 (not even checking other browsers) (甚至不检查其他浏览器)

What's the reason for it not working?它不起作用的原因是什么?

The problem is not just with your css code lacking second argument but with the image file.问题不仅在于您的 css 代码缺少第二个参数,还在于图像文件。

If you simply resize, make it smaller (i tried 32px for testing purposes) it works like a charm.如果您只是调整大小,将其缩小(我尝试 32px 用于测试目的)它就像一个魅力。

You might also want "pointer" rather than auto, judging by the look of the image;从图像的外观来看,您可能还需要“指针”而不是自动;

cursor: url('http://anuary.com/dev/hp/pad3/public/images/hand-cursor.png'), pointer;

EDIT : i realize now you wanted to keep the size but it just won't work.编辑:我现在意识到你想保持大小,但它不起作用。 see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Basic_User_Interface/Using_URL_values_for_the_cursor_property for more info有关详细信息,请参阅https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Basic_User_Interface/Using_URL_values_for_the_cursor_property

Firefox requires a second non-url argument such as Firefox 需要第二个非 url 参数,例如

cursor: url('http://anuary.com/dev/hp/pad3/public/images/hand-cursor.png'), auto;

There is a great reference at Quirksmode CSS2 - Cursor Styles Quirksmode CSS2有一个很好的参考 - Cursor Styles

The reason this is not working is maybe that you're doing this: cursor:url(https://example.com/example.png) You have to add , auto after the statement.这不起作用的原因可能是您正在执行此操作: cursor:url(https://example.com/example.png)您必须在语句之后添加, auto Therefore, this is what you are looking for.因此,这就是您要寻找的。 cursor:url(https://example.com/example.png),auto; Here's the clippet.这是剪辑。

 button {cursor:url("data:image/x-icon;base64,AAACAAEAICAAAAAAAACoCAAAFgAAACgAAAAgAAAAQAAAAAEACAAAAAAAAAQAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAP8IAP8RAAAA/+YABP8AAAD/iAAAav8AAP+3AACi/wALCxIAAHP/APL/AAAA6v8AALv/AACV/wDQ/wAAAP8RAAD/9wAAe/8AACb/AABV/wAAAP8A/8gAAP/3AAAA+/8AAP8aAF7/AAAA/1EA/////////////////////////////////////////////////8/////H////w////cPH//zDg//8Q5P//AOD//wDx//8A////AP///wH///8DgH//AwA//wAAH/4AAB/+AAf//AAD//wAAf/4AAD/+Af///Af///wf///8f////"),auto;}
 <button>Hover over me!</button>
Is this what you looked for? 这是你要找的吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM