<button class="shiny">Let in shiiine 🎶</button>
body {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
}
.shiny {
color: white;
position: relative;
border: none;
padding: 10px 15px;
background: #3984ff;
border-radius: 10px;
font-weight: bold;
cursor: pointer;
overflow: hidden;
}
.shiny::after {
content: "";
position: absolute;
top: calc(var(--y, 0) * 1px - 50px);
left: calc(var(--x, 0) * 1px - 50px);
width: 100px;
height: 100px;
background: radial-gradient(white, #3984ff00 80%);
opacity: 0;
transition: opacity 0.2s;
}
.shiny:hover::after {
opacity: 0.4;
}
const button = document.querySelector(".shiny");
const readout = document.querySelector("p");
button.addEventListener("mousemove", (e) => {
const { x, y } = button.getBoundingClientRect();
button.style.setProperty("--x", e.clientX - x);
button.style.setProperty("--y", e.clientY - y);
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.