JS实例-自定义光标


<
svg
xmlns="http://www.w3.org/2000/svg" id="cursor" viewBox="0 0 1024 1024" width="200" height="200" t="1564321121167" p-id="2713" version="1.1">
<path fill="#666666" d="M 539.264 631.68 L 352.576 818.368 L 163.2 131.2 l 687.168 189.44 L 663.68 507.264 l 195.328 195.264 L 796.8 764.8 l -97.664 -97.664 L 796.8 764.8 l -62.272 62.208 L 539.264 631.68 Z" p-id="2714" /></svg>
var body=document.body;    //隐藏光标
body.style="cursor:none";
var cursor=document.getElementById("cursor");    //初始化光标元件
var cursorScale=0.2;
var cursorXpy=-7;
var cursorYpy=-6;
cursor.setAttribute("width",cursor.getAttribute("width")*cursorScale);
cursor.setAttribute("height",cursor.getAttribute("height")*cursorScale);
cursor.style="position:fixed;left:0;top:0";
window.addEventListener("mousemove",function(){
	cursor.style.left=event.clientX+cursorXpy+"px";
	cursor.style.top=event.clientY+cursorYpy+"px";
});

转载于:https://www.cnblogs.com/yangjiale/p/11261243.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值