这里的要点是将div的位置设置为鼠标作为附加效果,它应该有一个半径,但它不起作用:
let inner_circle = document.getElementById("inner_circle"); window.addEventListener("mousemove", function(mouse) { inner_circle.style.transform = `translate(${mouse.clientX}px, ${mouse.clientY}px)`; // sets the position of the inner circle to the mouse });
#inner_circle{ margin-left: -3px; margin-top: -3px; position: fixed; top: 0; left: 0; border: 1px solid #703be7; border-radius: 50%; //<- doesn't work font-size: 1px; background-color: #703be7; width: 6px; width: 6px; z-index: 1000001; pointer-events: none; }
<div id="inner_circle"></div>
P粉1079910302024-04-01 12:09:34
更改你的 CSS。宽度:6 像素;宽度:6 像素;宽度:6px;高度:6px;
let inner_circle = document.getElementById("inner_circle"); window.addEventListener("mousemove", function(mouse) { inner_circle.style.transform = `translate(${mouse.clientX}px, ${mouse.clientY}px)`; // sets the position of the inner circle to the mouse });
#inner_circle{ margin-left: -3px; margin-top: -3px; position: fixed; top: 0; left: 0; border: 1px solid #703be7; border-radius: 50%; //<- doesn't work font-size: 1px; background-color: #703be7; width: 6px; height: 6px; z-index: 1000001; pointer-events: none; }
sssccc
P粉1254505492024-04-01 10:44:17
我假设你指的是这里第二行的高度,这使得它成为一个问题
#inner_circle{ width: 6px; width: 6px; }
所以只需将其更改为高度:
#inner_circle{ width: 6px; height: 6px; }