我希望实现的是将光标的位置添加悬停效果,类似于这个网站:https://drmportal.com/。下面是我提供的fiddle链接:https://jsfiddle.net/onnmwyhd/。以下是我的代码。
HTML
<div id="container"></div>
CSS
#container{
background-color: #6fc39a;
height:200px;
}
jQuery
$("#container").mousemove(function(e){
var x = e.pageX - this.offsetLeft;
var y = e.pageY - this.offsetTop;
$(this).html("X: " + x + " Y: " + y);
});
这是我想要在光标位置的颜色...
background-image: -webkit-linear-gradient(-35deg, #35a28e, #a8e4a5);