本文介绍了Microsoft Edge上的自定义光标有偏移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用CSS属性的游标,可在Chrome和Firefox上使用自定义游标。但是,在Microsoft Edge上,光标似乎具有偏移量。为了准确地选择项目,我必须稍微对准自定义光标上方。

I have a custom cursor working on Chrome and Firefox by using the CSS property, cursor. However, on Microsoft Edge, the cursor seems to have an offset. I have to aim above my custom cursor a bit in order to select items accurately.

我可以做些什么来解决此问题?还是这种限制?

Is there something I can do to fix this? Or is this some sort of limitation?

编辑:我应该提到我使用自定义图像作为光标。

I should mention that I'm using a custom image as my cursor.

推荐答案

在IE和Edge中,仅支持.cur文件,请参见。 (Edge支持其他格式,但不支持您在对Martin Beeby的答案发表评论时提到的交互点定义,使这些交互点变得毫无用处。).cur文件允许您定义交互点。只需在Google上搜索 .cur编辑器,然后选择适合您的编辑器即可创建.cur文件。

In both IE and Edge only .cur files are supported, see https://msdn.microsoft.com/en-us/library/aa358795(v=vs.85).aspx. (Edge supports other formats but not the interaction point definition as you mentioned in your comment to Martin Beeby's answer, rendering those pretty useless.) The .cur file allows you to define the interaction point. Just google for ".cur editor" and choose the editor that suits you to create a .cur file.

由于其他浏览器的确支持交互点的定义,但不支持.cur格式,因此必须在CSS中定义两个光标属性,第一个带有.cur属性。文件,第二个具有.png或其他格式以及交互点定义。 IE和Edge将忽略第二个,对于其他浏览器,.cur文件将被覆盖,这样它将跨浏览器工作。

Since other browsers do support the definition for the interaction point, but not the .cur format, you must define two cursor properties in your css, the first with the .cur file and the second with a .png or other format and the interaction point definition. IE and Edge will ignore the second and for other browsers the .cur file will be overwritten, that way it'll work cross-browser.

div {
    cursor: url(path/to/cursor.cur), auto; /*IE and Edge*/
    cursor: url(path/to/cursor.png) 4 12, auto; /*Chrome, FF, etc.*/
}

请注意阅读此内容()文章。这是关于IE 6及更高版本中的相对路径错误。 7,但该错误仍在IE 11中存在。尽管如此,该错误似乎在Edge中得到了解决(至少在最近尝试过时)。因此,您需要弄一点.cur文件的路径,以使其在IE和Edge上均可使用。请参阅本文中提到的解决方法。

One side note, be sure to read this (http://blog.stchur.com/2006/11/02/ie-bug-dealing-with-css-custom-cusors/) article. It's about a relative path bug in IE 6 & 7, but the bug is still around in IE 11. The bug seems resolved in Edge though (at least when I tried recently). So you need to fiddle a bit with the path to the .cur file to get it working on both IE and Edge. See the workarounds mentioned in the article.

这篇关于Microsoft Edge上的自定义光标有偏移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 22:45
查看更多