将鼠标光标更改为精灵div

时间:2021-11-29 20:23:33

For example, we usually use:

例如,我们通常使用:

style.cursor="url("+url here+"),auto";

The issue is, this creates a HTTP request if the image is not already rendered. Is it possible to set the mouse cursor style to a, for example:

问题是,如果图像尚未呈现,则会创建HTTP请求。是否可以将鼠标光标样式设置为a,例如:

<div class="sprite mouseimageclasshere"></div>

instead of it having to be a direct link to an image? This way, there is no unnecessary HTTP requests sent. (Of course once the user has loaded the sprite image already).

而不是必须是图像的直接链接?这样,就没有发送不必要的HTTP请求。 (当然,一旦用户加载了精灵图像)。

1 个解决方案

#1


0  

In general, you can have a base64-encoded data-URI wherever you have an URL.

通常,只要有URL,就可以使用base64编码的数据URI。

There are some border cases (size limits in old IEs, can't have certain file types), but images are ok in general. It's possible that mouse cursors are one of the exceptions to the rule, it should be worth a try. (If you put up a fiddle and a cursor file, it's easier for us to provide an example.)

有一些边界情况(旧IE中的大小限制,不能有某些文件类型),但图像一般都可以。鼠标游标可能是规则的例外之一,值得一试。 (如果你把小提琴和光标文件放在一起,我们就更容易提供一个例子。)

#1


0  

In general, you can have a base64-encoded data-URI wherever you have an URL.

通常,只要有URL,就可以使用base64编码的数据URI。

There are some border cases (size limits in old IEs, can't have certain file types), but images are ok in general. It's possible that mouse cursors are one of the exceptions to the rule, it should be worth a try. (If you put up a fiddle and a cursor file, it's easier for us to provide an example.)

有一些边界情况(旧IE中的大小限制,不能有某些文件类型),但图像一般都可以。鼠标游标可能是规则的例外之一,值得一试。 (如果你把小提琴和光标文件放在一起,我们就更容易提供一个例子。)