<button class="btn_clip" href="#"><span>Эффект фонарика</span><span>Эффект фонарика</span></button>
.btn_clip {
position: relative;
width: 500px;
align-items: center;
padding: 22px 35px 27px 35px;
border-radius: 0px 15px 15px 15px;
overflow: hidden;
background: #000;
color: #fff;
font-size: 24px;
display: inline-block;
text-decoration: none;
cursor: none;
border: none;
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
margin: 4px;
}
.btn_clip span {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #000;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
text-transform: uppercase;
letter-spacing: 2px;
pointer-events: none;
}
.btn_clip span:nth-child(2) {
color: #fff;
background: #000000;
overflow: hidden;
z-index: 2;
}
.btn_clip:hover span:nth-child(2) {
clip-path: circle(20px at var(--x) var(--y));
background-color: #f4e300;
color: #000000;
}
document.addEventListener("mousemove", (e => {
let a, b, c, d;
e.target.classList.contains("btn_clip") && (
a = e.target,
b = a.getBoundingClientRect(),
c = e.clientX - b.left,
d = e.clientY - b.top,
a.style.setProperty("--x", c + "px"),
a.style.setProperty("--y", d + "px")
);
}));
// Добавляем динамически копку
document.addEventListener("click", (e => {
let a;
e.target.classList.contains("btn_clip") && (
a = document.createElement("button"),
a.classList.add("btn_clip"),
a.innerHTML = "<span>Добавленная кнопка</span><span>Добавленная кнопка</span>",
a.setAttribute("href","#"),
document.body.append(a)
);
}));
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.