【CSS】@keyframesを使用してテキストを一文字ずつ上下から曲線上にアニメーションしながらフェードインさせる方法のデモページ

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

マイナビAGENT

DummyText01

DummyText02

スポンサーリンク

マイナビAGENT

HTML

<div class="block">
  <p class="top">DummyText01</p>
  <p class="bottom">DummyText02</p>
</div>

JavaScript

$(function(){
  $('.block p').children().addBack().contents().each(function() {
    $(this).replaceWith($(this).text().replace(/(\S)/g, '<span>$&</span>'));
  });
});
$(window).on('load', function(){
  $(".block").addClass("show");
});

CSS

.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);
  }
}