あなたのキモチ つなげるカタチ

TOP > CSS > 【CSS】上下から曲線上にアニメーションをさせながらテキストをフェードインする方法/How to animate text on a curve from above and below

【CSS】上下から曲線上にアニメーションをさせながらテキストをフェードインする方法/How to animate text on a curve from above and below

スポンサーリンク

コーディングテクニックの実装内容

上下から曲線上にアニメーションをさせながらテキストをフェードインする方法を紹介します。
CSSによってテキストを1文字ずつアニメーションさせます。

実装所要時間:10分程度
難易度:初心者コーダーでも実装可能

CSS,JavaScriptの記述内容

.block {
  margin: 70px auto 0;
  opacity: 0;
}

.block span {
  position: relative;
  display: inline-block;
  opacity: 0;
}

.block p {
  text-align: center;
  font-size: 25px;
}

.block.show {
  opacity: 1;
}

.block.show .top span:nth-child(0) {
  animation: move 1s linear 0s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(1) {
  animation: move 1s linear .1s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(2) {
  animation: move 1s linear .2s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(3) {
  animation: move 1s linear .3s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(4) {
  animation: move 1s linear .4s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(5) {
  animation: move 1s linear .5s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(6) {
  animation: move 1s linear .6s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(7) {
  animation: move 1s linear .7s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(8) {
  animation: move 1s linear .8s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(9) {
  animation: move 1s linear .9s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(10) {
  animation: move 1s linear 1s 1;
  animation-fill-mode: forwards;
}

.block.show .top span:nth-child(11) {
  animation: move 1s linear 1.1s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(0) {
  animation: move02 1s linear .4s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(1) {
  animation: move02 1s linear .5s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(2) {
  animation: move02 1s linear .6s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(3) {
  animation: move02 1s linear .7s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(4) {
  animation: move02 1s linear .8s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(5) {
  animation: move02 1s linear .9s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(6) {
  animation: move02 1s linear 1s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(7) {
  animation: move02 1s linear 1.1s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(8) {
  animation: move02 1s linear 1.2s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(9) {
  animation: move02 1s linear 1.3s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(10) {
  animation: move02 1s linear 1.4s 1;
  animation-fill-mode: forwards;
}

.block.show .bottom span:nth-child(11) {
  animation: move02 1s linear 1.5s 1;
  animation-fill-mode: forwards;
}

@keyframes move {
  0% {
    opacity: 0;
    transform: translate3d(36.5px, -59px, 0);
  }

  10% {
    opacity: .2;
    transform: translate3d(32.5px, -33.5px, 0);
  }

  20% {
    opacity: .4;
    transform: translate3d(27.5px, -16px, 0);
  }

  30% {
    opacity: .6;
    transform: translate3d(22.5px, -5.9px, 0);
  }

  40% {
    opacity: .8;
    transform: translate3d(17.5px, -1.3px, 0);
  }

  50% {
    opacity: 1;
    transform: translate3d(13px, 0px, 0);
  }

  60% {
    opacity: 1;
    transform: translate3d(9.5px, 0px, 0);
  }

  70% {
    opacity: 1;
    transform: translate3d(7px, 0px, 0);
  }

  80% {
    opacity: 1;
    transform: translate3d(5.6px, 0px, 0);
  }

  90% {
    opacity: 1;
    transform: translate3d(5px, 0px, 0);
  }

  100% {
    opacity: 1;
    transform: translate3d(5px, 0px, 0);
  }
}

@keyframes move02 {
  0% {
    opacity: 0;
    transform: translate3d(36.5px, 59px, 0);
  }

  10% {
    opacity: .2;
    transform: translate3d(32.5px, 33.5px, 0);
  }

  20% {
    opacity: .4;
    transform: translate3d(27.5px, 16px, 0);
  }

  30% {
    opacity: .6;
    transform: translate3d(22.5px, 5.9px, 0);
  }

  40% {
    opacity: .8;
    transform: translate3d(17.5px, 1.3px, 0);
  }

  50% {
    opacity: 1;
    transform: translate3d(12.9px, 0px, 0);
  }

  60% {
    opacity: 1;
    transform: translate3d(9.5px, 0px, 0);
  }

  70% {
    opacity: 1;
    transform: translate3d(7px, 0px, 0);
  }

  80% {
    opacity: 1;
    transform: translate3d(5.6px, 0px, 0);
  }

  90% {
    opacity: 1;
    transform: translate3d(6px, 0px, 0);
  }

  100% {
    opacity: 1;
    transform: translate3d(5px, 0px, 0);
  }
}

実装のポイント

現在制作中

スポンサーリンク

コメントを残す

メールアドレスが公開されることはありません。