Javascript 如何在网站上制作自定义光标?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14378200/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to make custom cursor on website?
提问by thezucknotes
Possible Duplicate:
CSS cursor customization
可能的重复:
CSS 光标自定义
I want the code for changing cursoron my site as it is given on the link below.
我想要在我的网站上更改光标的代码,因为它在下面的链接中给出。
I would also like to know how to do it. Please give a small code for this purpose.
我也想知道怎么做。请为此提供一个小代码。
回答by Minko Gechev
You can use custom image by:
您可以通过以下方式使用自定义图像:
body, html {
cursor: url(cursor.gif), pointer;
}
In urlthere's a path to the cursor image.
在url那里有一个指向光标图像的路径。
The cursor property may contain comma separated values of the allowed options: cursor: url(cursor.gif), url(cursor1.gif), pointer;.
cursor 属性可能包含允许选项的逗号分隔值:cursor: url(cursor.gif), url(cursor1.gif), pointer;。
An example here.
这里有一个例子。
Note: always specify at least one generic cursor in case that a URL-defined cursor can not be provided.
注意:如果无法提供 URL 定义的游标,请始终指定至少一个通用游标。
回答by Workonphp
In the CSS file you have to add a property on body tag as following:
在 CSS 文件中,您必须在 body 标签上添加一个属性,如下所示:
body{
cursor: anything like(pointer,default etc.)
}
If you want exactly same cursor as given in the site by you, then do as follow:
如果您想要与您在站点中给出的完全相同的光标,请执行以下操作:
cursor: url("http://safir85.ucoz.com/24work-blogspot/mouse-cursor/COOL_BLUE_OUTER_GLOW_POINTER-www.24work.blogspot.c.cur"), progress;
Think it will help.
认为它会有所帮助。
回答by Alvaro Louren?o
There's a css property for this: cursor. See in action in this example.
有这个CSS属性:cursor。请参阅本示例中的操作。

