问题描述
下面是我的代码,cursor1.cur图标与index.html位于同一根文件夹下.可以从以下链接下载cur图标: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/cursors/cursor1.cur
Below is my code, cursor1.cur icon is under the same root folder as index.html. The cur icon can be downloaded from this link: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/cursors/cursor1.cur
它在IE11中效果很好,但在Edge中不起作用.谁能帮我吗?
It works well in IE11, but doesn't work in Edge. Can anyone help me?
更新:如果将url1.cur替换为url: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/cursors/cursor1.cur .它也可以在Edge中使用.但是我仍然想知道如何在Edge中使用相对路径.
Update: if replace cursor1.cur with url: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/cursors/cursor1.cur. It works in Edge as well. But still I'd like to know how to use relative path in Edge.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
<style type="text/css">
#myP {
width: 200px;
height: 200px;
background-color: red;
cursor: url('cursor1.cur'), pointer;
}
</style>
</head>
<body>
Content of the document......
<p id="myP">
</p>
</body>
</html>
但是,我发现此示例可在IE11和Edge中使用: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/cursor_c.htm .这让我感到困惑,为什么我的代码仅适用于IE11.
However, I found this example works in both IE11 and Edge: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/cursor_c.htm. Which makes me confused about why my code only work for IE11.
推荐答案
我知道我参加晚会很晚,但是Edge还提供了另一种选择.只有.cur文件才能在Edge中用于设置自定义光标.您可以使用URL指向.cur文件,也可以使用项目中的本地资源路径.但是请确保不要在结尾括号和auto关键字之间放置任何数字.我的用例是更改Fabric js批注的光标.重要的部分是不要在末尾括号和auto关键字之间放置任何内容,否则Edge将忽略光标更改. Chrome和Firefox当然对此没有问题.
所以我检查它是否是Edge然后我用 freeDrawingCursor = 'url(http://cur.cursors-4u.net/others/oth-7/oth697.cur),auto';
如果是其他浏览器,则可以指定数字,例如 freeDrawingCursor = 'url(http://cur.cursors-4u.net/others/oth-7/oth697.cur) 0 34,auto';
您在网上看到的大多数答案都会显示正在使用的数字,因此请注意您的用户所使用的浏览器.
I know I am late to the party, but there is another option for Edge that I have come across. Only .cur files will work in Edge for setting a custom cursor. You can use a URL to a .cur file or the path in your project to a local resource. But be sure to not put any numbers between end parens and the auto keyword.My use case was changing the cursor for fabric js annotations. The important part is to not put anything between the end parens and the auto keyword or else Edge will ignore the cursor change. Chrome and Firefox of course have no problem with this.
So I check if it is Edge then I use freeDrawingCursor = 'url(http://cur.cursors-4u.net/others/oth-7/oth697.cur),auto';
and if it is a different browser I can specify numbers such as freeDrawingCursor = 'url(http://cur.cursors-4u.net/others/oth-7/oth697.cur) 0 34,auto';
Most answers you see online will show numbers being used so be aware of what browser your user is on.
这篇关于边缘自定义光标不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!