为什么 CSS 游标 属性 不能与自定义 URL 一起使用?
Why is the CSS cursor property not working with a custom URL?
CSS:
#cursor {
cursor: url(cursor.gif);
}
HTML:
<div id="cursor">
<p>Hello world!</p>
</div>
根据MDN:
zero or more URLs may be specified (comma-separated), which must be followed by one of the keywords defined in the CSS specification, such as auto
or pointer
.
因此您需要为 url()
.
定义游标值 fallback
例如,使用auto
:
#cursor {
width: 100px;
height: 100px;
border: 1px solid;
cursor: url(//placehold.it/20), auto;
}
<div id="cursor"></div>
CSS:
#cursor {
cursor: url(cursor.gif);
}
HTML:
<div id="cursor">
<p>Hello world!</p>
</div>
根据MDN:
zero or more URLs may be specified (comma-separated), which must be followed by one of the keywords defined in the CSS specification, such as
auto
orpointer
.
因此您需要为 url()
.
例如,使用auto
:
#cursor {
width: 100px;
height: 100px;
border: 1px solid;
cursor: url(//placehold.it/20), auto;
}
<div id="cursor"></div>