张森ZS

write code everyday

导航

解决:使用鼠标禁用符号不显示红色禁用符号

通常情况下,使用 cursor: no-drop 或者 cursor: not-allowed。查了很多资料,说是自动会给设置为红色边框的禁用符号。后来自己做实验,发现都是灰白色的禁用图标,包括京东也是如此:

如果想实现红色的图标应该怎么做呢?给 cursor 加上一个 url 的默认图片的参数。

格式:cursor: url( 图片路径 ), auto;

但是使用我本地的一个图片后,发现没有生效。后来继续查询:发现使用的图片的大小和分辨率是有限制的:

In Gecko (Firefox) the limit of the cursor size is 128×128px. Larger cursor images are ignored. However, you should limit yourself to the size 32×32 for maximum compatibility with operating systems and platforms.

后来重新换了一张图片,之后就可以通过展示图片来代替鼠标了。不过一个限制就是此时只会显示图片,而没有鼠标的箭头了,目前最好的方案应该就是这个了。可以把图片替换为需要想要的任何形状和颜色的图片。

参考:https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Basic_User_Interface/Using_URL_values_for_the_cursor_property#limitations

posted on 2021-04-09 11:09  张森ZS  阅读(546)  评论(0编辑  收藏  举报