自定义光标图像在所有IE中都不起作用?

jil*_*ego 12 css internet-explorer cursor

我想我已尝试过在互联网上建议的不同方法,但没有任何效果.这是我目前的css代码:

div {
   cursor: url(images/zoomin.cur), auto;
}
Run Code Online (Sandbox Code Playgroud)

它在IE中工作正常...

Jas*_*aro 17

不幸的是,cursor在IE中是一个简单的错误,至少在8之前

在Internet Explorer for Windows(包括版本8)中,如果在外部样式表文件中指定了相对URI值,则基URI将被视为包含该元素的文档的URI,而不是其中样式表的URI声明出现了.

http://reference.sitepoint.com/css/cursor

您可能希望能够使用a conditional comment来定位IE,然后使用不同的方式为其提供修改后的样式规则url.

  • 目前IE 10中仍然存在错误 (2认同)

Ric*_*lpe 6

我以这种方式解决了Internet Explorer中的抓取光标问题,并引用了@JasonGennaro的答案:

在适用于Windows(包括8版)的Internet Explorer中,如果在外部样式表文件中指定了相对URI值,则将基本URI视为包含元素的文档的URI,而不是其中包含样式表的URI。声明出现。

.grab_cursor {
    cursor: grab;
    cursor: -moz-grab;
    cursor: -webkit-grab;
    cursor: url('../img/cursors/openhand.cur'), url('img/cursors/openhand.cur'), n-resize; /* standard: note the different path for the .cur file */
    cursor: url('img/cursors/openhand.cur'), n-resize\9; /* IE 8 and below */
    *cursor: url('img/cursors/openhand.cur'), n-resize; /* IE 7 and below */
    _cursor: url('img/cursors/openhand.cur'), n-resize; /* IE 6 */
}
Run Code Online (Sandbox Code Playgroud)

文件树

index.html
css/style.css -> here the posted code
img/cursors/openhand.cur
Run Code Online (Sandbox Code Playgroud)

好的参考文献

工作演示