能否使用glyphicon创建自定义光标?

3

我在想是否可以用glyphicon制作自定义光标。我能想到的一种方法是在页面主体上设置光标属性为none,在基于jquery mousemove x、y坐标的绝对定位下将glyphicon z-index设置为最顶层。这样做是否正确,或者有没有其他本地方法?


你现在尝试了什么? - Sachin Kanungo
1
http://stackoverflow.com/questions/1144836/css-cursor-customization - guest271314
最简单的方法是制作图标的屏幕截图,并使用位图鼠标指针。你可以尝试使用html2canvas来实现动态生成图像的高级效果。 - dandavis
1个回答

3

虽然我没有找到原生的方法来实现这个功能,但是这里有一个使用jquery和css属性的方法。

#test{
    width:200px;
    height:200px;
    cursor:none;
    background-color:#ff0000;
}

#mycur{
    position:absolute;
    z-index:1000;
    cursor:none;
}

$("#test").mousemove(function(e){
    mycur=$("#mycur");
    mycur.css("left",e.offsetX);
    mycur.css("top",e.offsetY);
});

<div id="test">
</div>
<i id="mycur" class="fa fa-paint-brush"></i>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接