【CSS】@keyframesを使用してテキストを揺らすようにノイズを加えるエフェクトの実装方法のデモページ

※デベロッパーツール等でソースコードをご確認ください(Please check using Developer tools)

このページの内容が難しいと感じた方はこちら

DUMMEY TEXT

スポンサーリンク

Web制作会社LIGが運営するWebデザインスクール

CSS

body {
  background: #000;
}

.block {
  margin: 70px 0 0;
}

.block p {
  position: relative;
  overflow: hidden;
  text-align: center;
  font-size: 70px;
  color: #fff;
}

.block p:before {
  content: attr(data-text);
  position: absolute;
  left: -2px;
  text-shadow: 1px 0 blue;
  top: 0;
  width: 100%;
  height: 100%;
  color: white;
  background: transparent;
  animation: noise-anime-2 3s infinite linear alternate-reverse;
}
.block p:after {
  content: attr(data-text);
  position: absolute;
  left: 1px;
  width: 100%;
  height: 100%;
  text-shadow: -1px 0 red;
  top: 0;
  color: white;
  background: transparent;
  animation: noise-anime 4s infinite linear alternate-reverse;
}

@keyframes noise-anime {
  0% {
    clip: rect(89px, 9999px, 95px, 0);
  }
  5% {
    clip: rect(58px, 9999px, 98px, 0);
  }
  10% {
    clip: rect(96px, 9999px, 92px, 0);
  }
  15% {
    clip: rect(58px, 9999px, 65px, 0);
  }
  20% {
    clip: rect(69px, 9999px, 7px, 0);
  }
  25% {
    clip: rect(8px, 9999px, 3px, 0);
  }
  30% {
    clip: rect(8px, 9999px, 76px, 0);
  }
  35% {
    clip: rect(43px, 9999px, 25px, 0);
  }
  40% {
    clip: rect(55px, 9999px, 67px, 0);
  }
  45% {
    clip: rect(57px, 9999px, 59px, 0);
  }
  50% {
    clip: rect(85px, 9999px, 14px, 0);
  }
  55% {
    clip: rect(2px, 9999px, 42px, 0);
  }
  60% {
    clip: rect(89px, 9999px, 98px, 0);
  }
  65% {
    clip: rect(47px, 9999px, 6px, 0);
  }
  70% {
    clip: rect(57px, 9999px, 20px, 0);
  }
  75% {
    clip: rect(71px, 9999px, 39px, 0);
  }
  80% {
    clip: rect(99px, 9999px, 19px, 0);
  }
  85% {
    clip: rect(73px, 9999px, 66px, 0);
  }
  90% {
    clip: rect(23px, 9999px, 75px, 0);
  }
  95% {
    clip: rect(1px, 9999px, 56px, 0);
  }
  100% {
    clip: rect(26px, 9999px, 96px, 0);
  }
}
@keyframes noise-anime-2 {
  0% {
    clip: rect(37px, 9999px, 16px, 0);
  }
  5% {
    clip: rect(42px, 9999px, 39px, 0);
  }
  10% {
    clip: rect(74px, 9999px, 32px, 0);
  }
  15% {
    clip: rect(25px, 9999px, 60px, 0);
  }
  20% {
    clip: rect(74px, 9999px, 94px, 0);
  }
  25% {
    clip: rect(6px, 9999px, 12px, 0);
  }
  30% {
    clip: rect(70px, 9999px, 13px, 0);
  }
  35% {
    clip: rect(21px, 9999px, 19px, 0);
  }
  40% {
    clip: rect(85px, 9999px, 70px, 0);
  }
  45% {
    clip: rect(38px, 9999px, 26px, 0);
  }
  50% {
    clip: rect(37px, 9999px, 51px, 0);
  }
  55% {
    clip: rect(60px, 9999px, 1px, 0);
  }
  60% {
    clip: rect(86px, 9999px, 17px, 0);
  }
  65% {
    clip: rect(27px, 9999px, 16px, 0);
  }
  70% {
    clip: rect(51px, 9999px, 60px, 0);
  }
  75% {
    clip: rect(9px, 9999px, 29px, 0);
  }
  80% {
    clip: rect(22px, 9999px, 41px, 0);
  }
  85% {
    clip: rect(2px, 9999px, 82px, 0);
  }
  90% {
    clip: rect(75px, 9999px, 18px, 0);
  }
  95% {
    clip: rect(48px, 9999px, 25px, 0);
  }
  100% {
    clip: rect(73px, 9999px, 98px, 0);
  }
}

@media screen and (max-width:640px){
  .block p {
    font-size: 30px;
  }
}