【jQuery】テキストを一文字ずつ立体的にフェードインさせる方法のデモページ

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

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

DummyText

実装のポイント

スポンサーリンク

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

HTML

<div class="wrap">
  <p class="text">DummyText</p>
</div>

JavaScript

$(function(){
  $('.text').children().addBack().contents().each(function() {
      $(this).replaceWith($(this).text().replace(/(\S)/g, '<span class="text-move">$&</span>'));
  });
   setTimeout(function(){
      $(".text").addClass("active");
  },100);
});

CSS

.wrap {
  width: 768px;
  margin: 0 auto;
}
.text {
  margin: 50px 0 0;
  text-align: center;
  opacity: 0;
}

.text-move {
  opacity: 0;
  display: inline-block;
  transform: scale(1.25) translate(8px, 4px);
  font-size: 80px;
  letter-spacing: 0.02em;
}

.text-move:nth-child(1) {
  transition: opacity 1.2s ease 0.1s, transform 1.2s ease 0.2s;
}
.text-move:nth-child(2) {
  transition: opacity 1.2s ease 0.2s, transform 1.2s ease 0.25s;
}
.text-move:nth-child(3) {
  transition: opacity 1.2s ease 0.25s, transform 1.2s ease 0.3s;
}
.text-move:nth-child(4) {
  transition: opacity 1.2s ease 0.3s, transform 1.2s ease 0.35s;
}
.text-move:nth-child(5) {
  transition: opacity 1.2s ease 0.35s, transform 1.2s ease 0.4s;
}
.text-move:nth-child(6) {
  transition: opacity 1.2s ease 0.4s, transform 1.2s ease 0.45s;
}
.text-move:nth-child(7) {
  transition: opacity 1.2s ease 0.45s, transform 1.2s ease 0.5s;
}
.text-move:nth-child(8) {
  transition: opacity 1.2s ease 0.5s, transform 1.2s ease 0.55s;
}
.text-move:nth-child(9) {
  transition: opacity 1.2s ease 0.55s, transform 1.2s ease 0.6s;
}
.text-move:nth-child(10) {
  transition: opacity 1.2s ease 0.6s, transform 1.2s ease 0.65s;
}
.text-move:nth-child(11) {
  transition: opacity 1.2s ease 0.65s, transform 1.2s ease 0.7s;
}
.text-move:nth-child(12) {
  transition: opacity 1.2s ease 0.7s, transform 1.2s ease 0.75s;
}

.text.active {
  opacity: 1;
}

.text.active .text-move {
  opacity: 1;
  transform: scale(1) translate(0);
}

@media screen and (max-width:640px){
  .wrap {
    width: 100%;
  }
  .text-move {
    font-size: 30px;
  }
}