我在拉斐尔空间上有一些矩形。我设置了一个快速鼠标坐标显示来精确放置对象:document.addEventListener("mousemove",function(event){ var x = event.clientX; var y = event.clientY; document.getElementById('position').innerHTML = " X = "+ x +" Y = "+ y; });然而,似乎矩形往往比预期的位置高出大约 10 像素。为什么会这样?(我也知道使用style而不是 css 文件是不好的做法,但我只是想直接玩弄拉斐尔而不用担心)var p = Raphael("paper");let r1, r2, r3, l1;r1 = p.rect(200, 200, 40, 40) .attr({ 'fill': 'red', 'cursor': 'pointer', 'href': 'https://www.google.com/', });r2 = p.rect(277, 320, 50, 50) .attr({ 'fill': 'blue', 'cursor': 'pointer', 'href': 'https://www.google.com/', });p.path("M 200,200 L 240,240");r3 = p.rect(377, 300, 30, 80) .attr({ 'fill': 'yellow', 'cursor': 'pointer', 'href': 'https://www.google.com/', });document.addEventListener("mousemove", function(event) { var x = event.clientX; var y = event.clientY; document.getElementById('position').innerHTML = " X = " + x + " Y = " + y;});<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>tester2</title> <script src="raphael-min.js"></script></head><body> <div id="content"> <div id="paper"></div> </div> <p id="position">Test</p> <style> #paper { height: 500px; width: 500px; border: 1px solid black; } </style></body>我怀疑我的鼠标坐标系只是关闭,但如果是这样,我不知道如何相对于 Raphael("paper");问题的实时链接:https : //jsfiddle.net/oLwydha6/
添加回答
举报
0/150
提交
取消