Hovered text will change color at the mouse location
P粉697408921
P粉697408921 2024-03-28 14:12:45
0
1
497

How to change only the text color at the mouse location instead of the color of all text? like this

I want the circle that you can see to follow the mouse movement, and on hover the text only shows a border for the portion of the letter in hover

I need advice on which library or function I need to use?

P粉697408921
P粉697408921

reply all(1)
P粉936568533

const fx = document.querySelector(".fx");

document.addEventListener("pointermove", e => {
  fx.style.top = e.clientY + "px";
  fx.style.left = e.clientX + "px";
  fx.querySelector("h1").style.transform = `translate(${(e.clientX - fx.getBoundingClientRect().width / 2) * -1}px, ${(e.clientY - fx.getBoundingClientRect().height / 2) * -1}px)`;
})
* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

.container {
  position: relative;
}

.container h1 {
  font-size: 10rem;
  color: red;
}

.container .fx {
  width: 100px;
  height: 100px;
  outline: 1px solid blue;
  border-radius: 50%;
  position: absolute;
  top: -100px;
  left: -100px;
  overflow: hidden;
  transform: translate(-50%, -50%);
  background-color: white;
}

.container .fx h1 {
  font-size: 10rem;
  color: transparent;
  -webkit-text-stroke: 2px green;
  cursor: default;
  position: relative;
}

abc

abc

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template