简体   繁体   English

css自定义光标不起作用

[英]css custom cursor not working

I am using the css custom cursor to use an image for the cursor.我正在使用 css 自定义光标为光标使用图像。 The image doesn't work.图像不起作用。 What is wrong with this code?这段代码有什么问题?
Here is the image used.是使用的图像。 Fiddle小提琴

 cursor: url('http://www.sarkelliancreed.comule.com/pics/TREES.jpg'), auto;

I was dealing with this problem last night.我昨晚正在处理这个问题。 The issue is that there is a limit to the size of the image you can use as a cursor.问题是您可以用作光标的图像大小是有限制的。 If you really need an image that large to follow the cursor, have a div with that image snap to the cursor position on the mousemove event.如果你真的需要一个那么大的图像来跟随光标,那么在 mousemove 事件上让一个带有该图像的 div 捕捉到光标位置。

MDN at least describes the size limit for Firefox: MDN 至少描述了 Firefox 的大小限制:

In Gecko (Firefox) the limit of the cursor size is 128×128px.在 Gecko (Firefox) 中,光标大小的限制是 128×128px。 Larger cursor images are ignored.较大的光标图像将被忽略。 However, you should limit yourself to the size 32×32 for maximum compatibility with operating systems and platforms.但是,您应该将自己限制为 32×32 的大小,以最大程度地兼容操作系统和平台。

MDN documentation for cursor property in CSS CSS 中光标属性的 MDN 文档

Put in this smiley rather than the image you're using as the URL and run the Fiddle again, and it works: http://icons-search.com/img/icons-land/IconsLandVistaStyleEmoticonsDemo.zip/IconsLandVistaStyleEmoticonsDemo-ICO-Cool.ico-32x32.png放入这个笑脸而不是您使用的图像作为 URL 并再次运行 Fiddle,它可以工作:http: //icons-search.com/img/icons-land/IconsLandVistaStyleEmoticonsDemo.zip/IconsLandVistaStyleEmoticonsDemo-ICO-Cool .ico-32x32.png

Any type of file format won't work, only .cur files.任何类型的文件格式都不起作用,只有.cur文件。

cursor: url('http://www.sarkelliancreed.comule.com/pics/TREES.cur'), auto;

source: https://fb.watch/dRdLF-vwD2/来源: https ://fb.watch/dRdLF-vwD2/

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

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