我给鼠标绑定了移动事件,且跟随了一个图片
页面中的文字无法选中,悬停效果也没有了
var iconFollow = document.querySelector('.icon-follow');
document.addEventListener('mousemove', function(e) { /*mousemove鼠标移动事件*/
// 把x,y坐标作为图片的top,left值,(注意:top/left的属性值都带px)
iconFollow.style.left = e.pageX + 'px';
iconFollow.style.top = e.pageY + 'px'; /*高度往上走是负*/
});
可能时由于onmousemove的返回值被我重新设置了么?页面就无法正确捕捉到了
暂时想不出解决办法,没有搜出结果
页面元素能正常选中,能有交互效果
增加点偏移量,要不选择的时候直接就是按着这个图片选图片了。
var iconFollow = document.querySelector('.icon-follow');
document.addEventListener('mousemove', function (e) { /*mousemove鼠标移动事件*/
// 把x,y坐标作为图片的top,left值,(注意:top/left的属性值都带px)
iconFollow.style.left = e.pageX+1 + 'px';//增加偏移量
iconFollow.style.top = e.pageY + 1 + 'px';//增加偏移量
});
你这种效果应该使用 cursor url 鼠标跟随 就不行 。都跟随了肯定 无法选中了
https://www.cnblogs.com/wdl818/p/5941149.html
https://www.runoob.com/cssref/pr-class-cursor.html