【CSS】How to implement text that changes color even within a single character and supports liquid layout(Demo page)

※Please check using Developer tools

Dummy Text. Dummy Text. Dummy Text. Dummy Text.
Dummy Text. Dummy Text. Dummy Text. Dummy Text.

Sponsored links

CSS

body {
  background: #cacaca;
}

.wrap {
  max-width: 900px;
  width: 100%;
  height: 500px;
  margin: 200px auto 0;
  word-break: break-all;
}

.main {
  position: relative;
  width: 100%;
  height: 100%
}

.inner {
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 100%;
  font-size: 53px;
}

.main .trim-title {
  position: absolute;
  top: 50px;
  right: 0;
  width: 88%;
  height: 4em;
  line-height: 1.5;
}

.trim-title span {
  display: block;
  position: absolute;
  left: -12%;
}

.main .trim-title span {
  top: 0;
  height: 100%;
  color: #000;
}

.trim-front {
  z-index: 3;
}

.trim-back {
  z-index: 1;
}

.trim-title.front span {
  color: #ffffff;
}

.trim-title.front {
  overflow: hidden;
}

@media screen and (max-width:640px){
  .wrap {
    max-width: 95%;
    margin: 0 auto;
    height: 150px;
  }
  .inner {
    font-size: 20px;
  }
}