我已经创建了一个光标使用html,css和JavaScript这是建立在this website现在的问题是光标是移动,但不像在这个网站上缩放缩小与光标移动我希望光标移动在这个网站上沿着缩小。我怎么才能使它?
document.addEventListener("DOMContentLoaded", function() {
const cursor = document.querySelector(".custom-cursor");
document.addEventListener("mousemove", function(e) {
const x = e.clientX;
const y = e.clientY;
cursor.style.transform = `translate(${x}px, ${y}px)`;
});
});
body {
cursor: none; /* Hide the default cursor */
margin: 0;
overflow: hidden;
}
.custom-cursor {
position: fixed;
width: 20px;
height: 20px;
background-color: #ff0000; /* Choose your desired color */
border-radius: 50%;
pointer-events: none;
transition: transform 0.2s ease-out;
transform-origin: center;
}
<body>
<div class="custom-cursor"></div>
</body>
1条答案
按热度按时间hmmo2u0o1#
也许是这样的东西?可能有点小故障