Is it possible to put the mouse cursor behind an element or does the mouse cursor have an z-index?

妖精的绣舞 提交于 2019-12-04 12:22:24

Question

is there a way to put the mouse cursor behind the hand?

The reason you see the mouse pointer when you move the mouse fast is that you occasionally end up with the cursor over the pointer, thus the .hoverbox:hover style is not applied.

In your mousemove event binding add the css style for cursor: none also to the pointer and you should not see the mouse pointer at all anymore even when accidentally moving over the hand. Applying the cursor: none to the .pointer:hover in CSS does not work as well.

$(".hoverBox").mousemove(function(e) {
    var tWidth = $(window).width();
    var position = $(this).position();
    var fingerPosition = position.top + e.clientY + 15;
    var fingerWidth = $(this).parent().find('.pointer').width();

    $('.pointer').css('display', 'none').css('top', fingerPosition).css('left', e.clientX - fingerWidth - 15).css('display', 'block').css('cursor', 'none');
});

DEMO - Hiding cursor when over pointer

Edit
I could not get the cursor: url() to work in fiddler but I'm guessing this is mainly down to the fact that fiddler renders output trough fiddle.jshell.net and the image might have to be local to the server.

But if all you want to use is a pointer-hand, you could always use the cursor: pointer style as well.

CSS:

.hoverBox {
    width: 400px;
    height: 300px;
    background: black;
    cursor: pointer;
}

DEMO - Using the default pointer cursor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!