Wave Text

波打つテキストエフェクト。
各文字が波のように上下するアニメーションです。

Demo

HTML index.html

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Wave Text</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="wave-text" data-text="WAVE EFFECT"></div>
  <script src="script.js"></script>
</body>
</html>

CSS style.css

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  overflow: hidden;
}

.wave-text {
  font-size: 5rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  position: relative;
  cursor: pointer;
}

.wave-text span {
  display: inline-block;
  animation: wave 1.5s ease-in-out infinite;
  background: linear-gradient(45deg, #ff0080, #ff8c00, #40e0d0, #ff0080);
  background-size: 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: wave 1.5s ease-in-out infinite, gradient 3s ease infinite;
}

@keyframes wave {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes gradient {
  0%, 100% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
}

@media (max-width: 768px) {
  .wave-text {
    font-size: 3rem;
  }
}

JS script.js

const waveText = document.querySelector('.wave-text');
const text = waveText.getAttribute('data-text');

// テキストを文字ごとに分割してspanで囲む
waveText.innerHTML = '';
text.split('').forEach((char, index) => {
  const span = document.createElement('span');
  span.textContent = char === ' ' ? '\u00A0' : char;
  span.style.animationDelay = `${index * 0.1}s`;
  waveText.appendChild(span);
});

// ホバーでアニメーション再開
waveText.addEventListener('mouseenter', () => {
  const spans = waveText.querySelectorAll('span');
  spans.forEach((span, index) => {
    span.style.animation = 'none';
    setTimeout(() => {
      span.style.animation = 'wave 1.5s ease-in-out infinite, gradient 3s ease infinite';
      span.style.animationDelay = `${index * 0.05}s`;
    }, 10);
  });
});

Download

すべてのファイルをZIP形式でダウンロードできます。