【CSS】How to animate text with a different color than the text color using transition | Demo page

※Please check using Developer tools

Dummytext01Dummytext01

Dummytext01Dummytext01

Sponsored links

CSS

body {
  background: #ddd;
}
.block {
  position: relative;
  margin: 70px 0 0;
  text-align: center;
  font-size: 50px;
}

.block div {
  overflow: hidden;
  width: 0;
}

.block div p {
  width: 100vw;
  word-wrap: break-word;
}

.block div:first-child {
  color: #fff;
  transition: width 1.5s cubic-bezier(0.2, 1, 0.2, 1), opacity 0.5s ease 1.5s;
}

.block div:nth-child(2) {
  position: absolute;
  left: 0;
  top: 0;
  transition: width 1.5s cubic-bezier(0.2, 1, 0.2, 1) 0.2s;
}

.block.active div {
  width: 100%;
}

.block.active div:first-child {
  opacity: 0;
  filter: alpha(opacity=0);
}

JavaScript

$(window).on('load', function(){
  $(".block").addClass("active");
});