简体   繁体   English

使用自定义光标调整鼠标位置

[英]Adjusting mouse position with custom cursor

I'm currently experimenting with large custom cursor on hover and I'd like to make the hover a little more accurate.我目前正在尝试在悬停时使用大型自定义光标,我想让悬停更准确一些。 I'd like to center the cursor in the image not to be top left.我想将光标放在图像中而不是左上角。 I'm not sure exactly which method would the be the best, any tips on that ?我不确定究竟哪种方法是最好的,有什么提示吗?

Here's a quick example: https://codepen.io/kombolo/pen/MWYpaXj这是一个简单的例子: https : //codepen.io/kombolo/pen/MWYpaXj

<div class="el"> Hello World </div>

.el {
  margin-top:100px;
  width: 100vw;
  height:100px;
  font-size:128px;
  text-align:center;
  cursor: url("http://www.tsi.enst.fr/pages/enseignement/ressources/mti/quat_TF/pages-site/images/applic40.jpg"), auto;
}

Thanks谢谢

You can change the cursor's 'hotspot' position in pixels ( not really sure you can in % )您可以以像素为单位更改光标的“热点”位置(不确定您可以以 % 为单位)

cursor: url(your image) posX posY, auto;

 .el { margin-top:100px; width: 100vw; height:100px; font-size:128px; text-align:center; cursor: url("http://www.tsi.enst.fr/pages/enseignement/ressources/mti/quat_TF/pages-site/images/applic40.jpg") 75 75, auto; }
 <div class="el"> Hello World </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM