TGViewer
Логово верстальщика Логово верстальщика @webdevlair · 7.89K subscribers
Post #2965 1.68K
👩‍💻 Кнопка с "волновым" эффектом

Создайте кнопку, при нажатии на которую появляется анимация "волн", расходящихся из точки клика.

Ожидаемое поведение:

• При нажатии на кнопку из точки клика расходится круг, который исчезает через мгновение.
• Анимация должна быть плавной и не мешать повторным кликам.

Решение задачи🔽

<button class="ripple-button">Нажми меня</button>

.ripple-button {
position: relative;
overflow: hidden;
padding: 10px 20px;
font-size: 16px;
color: white;
background-color: #007BFF;
border: none;
border-radius: 4px;
cursor: pointer;
}

.ripple-button .ripple {
position: absolute;
border-radius: 50%;
transform: scale(0);
animation: ripple-animation 0.6s linear;
background-color: rgba(255, 255, 255, 0.6);
}

@keyframes ripple-animation {
to {
transform: scale(4);
opacity: 0;
}
}

document.querySelector('.ripple-button').addEventListener('click', function (event) {
const ripple = document.createElement('span');
const rect = this.getBoundingClientRect();

ripple.style.width = ripple.style.height = `${Math.max(rect.width, rect.height)}px`;
ripple.style.left = `${event.clientX - rect.left - ripple.offsetWidth / 2}px`;
ripple.style.top = `${event.clientY - rect.top - ripple.offsetHeight / 2}px`;

ripple.className = 'ripple';
this.appendChild(ripple);

ripple.addEventListener('animationend', () => ripple.remove());
});
More from @webdevlair
  1. Oct 16, 2026Deno уходит в Cloudflare. С приветом от Node Спойлер: в Cloudflare команда Deno едет не ко…
  2. Oct 16, 2026Post #4695
  3. Oct 16, 2026Как вставлять иконки в веб, не трогая HTML Ли Веру показывает трюк: иконки настраиваются ч…
  4. Oct 16, 2026⚡️ В сети начали массово сливать IT-курсы и книги известных онлайн школ Вот отсортированна…
  5. Oct 15, 2026Post #4692
  6. Oct 14, 2026Автор ковыряет вёрстку с тех самых времён, когда Chrome был ещё первой версией, а не моноп…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →