набрав effect- css, чтобы написать полный текст - html


0

Я пытаюсь написать текст как печатный, но эффект ввода не полностью пишет длинный текст, и текст не перемещается на вторую строку, чтобы завершить написание текста.

Любой подход css приветствуется (избегая использования js или jquery).

    /* Google Fonts */
@import url(https://fonts.googleapis.com/css?family=Lato&display=swap);
    
    /* Global */
    html{
      min-height: 100%;
      overflow: hidden;
    }
    body{
      height: calc(100vh - 8em);
      padding: 4em;
      color: rgba(255,255,255,.75);
      font-family: Lato, sans-serif; 
      background-color: rgb(25,25,25);  
    }
    .line-1{
        position: relative;
        top: 50%;  
        width: 100%;
        border-right: 2px solid rgba(255,255,255,.75);
        font-size: 180%;
        text-align: left;
        white-space: nowrap;
        overflow: hidden;
        transform: translateY(-50%);    
    }
    
    /* Animation */
    .anim-typewriter{
      animation: typewriter 4s steps(44) 1s 1 normal both,
                 blinkTextCursor 500ms steps(44) infinite normal;
    }
    @keyframes typewriter{
      from{width: 0;}
      to{width: 100%;}
    }
    @keyframes blinkTextCursor{
      from{border-right-color: rgba(255,255,255,.75);}
      to{border-right-color: transparent;}
    }
    <p class="line-1 anim-typewriter">Animation typewriter style using css steps() Animation typewriter style using css steps() Animation typewriter style using css steps() Animation typewriter style using css steps()</p>

  •  53
  •  1
  • 11 май 2020 2020-05-11 10:17:13

1 ответ

0

Вы можете использовать эти дочерние операторы css, чтобы разбить ваш абзац и перейти к следующей строке.

.css-typing p {
  margin-left: -20px;
  color: black;
  text-align: center;
  border-right: .15em solid orange;
  font-family: "monospace";
  font-size: 2em;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
}

.css-typing p:nth-child(1) {
  width: 400px;
  -webkit-animation: type 2s steps(40, end);
  animation: type 2s steps(40, end);
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

.css-typing p:nth-child(2) {
  width: 400px;
  opacity: 0;
  -webkit-animation: type2 2s steps(40, end);
  animation: type2 2s steps(40, end);
  -webkit-animation-delay: 2s;
  animation-delay: 2s;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

.css-typing p:nth-child(3) {
  width: 400;
  opacity: 0;
  -webkit-animation: type3 2s steps(40, end), blink .2s step-end infinite alternate;
  animation: type3 2s steps(40, end), blink .2s step-end infinite alternate;
  -webkit-animation-delay: 4s;
  animation-delay: 4s;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

.css-typing p:nth-child(4) {
  width: 400px;
  opacity: 0;
  -webkit-animation: type4 2s steps(40, end);
  animation: type2 2s steps(40, end);
  -webkit-animation-delay: 6s;
  animation-delay: 6s;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

.css-typing p:nth-child(5) {
  width: 400px;
  opacity: 0;
  -webkit-animation: type5 2s steps(40, end);
  animation: type2 2s steps(40, end);
  -webkit-animation-delay: 8s;
  animation-delay: 8s;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

.css-typing p:nth-child(6) {
  width: 400px;
  opacity: 0;
  -webkit-animation: type6 2s steps(40, end);
  animation: type4 2s steps(40, end);
  -webkit-animation-delay: 10s;
  animation-delay: 10s;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

@keyframes type {
  0% {
    width: 0;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    border: none;
  }
}

@-webkit-keyframes type {
  0% {
    width: 0;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    border: none;
  }
}

@keyframes type2 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@-webkit-keyframes type2 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@keyframes type3 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@-webkit-keyframes type3 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@keyframes type4 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@-webkit-keyframes type4 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@keyframes type5 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@-webkit-keyframes type5 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  99.9% {
    border-right: .15em solid orange;
  }
  100% {
    opacity: 1;
    border: none;
  }
}

@keyframes type6 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

@-webkit-keyframes type6 {
  0% {
    width: 0;
  }
  1% {
    opacity: 1;
  }
  100% {
    opacity: 1;
  }
}

@keyframes blink {
  50% {
    border-color: transparent;
  }
}

@-webkit-keyframes blink {
  50% {
    border-color: tranparent;
  }
}
<div class="css-typing">
  <p>
    typewriter style
  </p>
  <p>
    Animation typewriter
  </p>
  <p>
    style using css
  </p>
  <p>
    steps() Animationy
  </p>
  <p>
    typewriter style using
  </p>
  <p>
    css steps().
  </p>
</div>

  • 11 май 2020 2020-05-11 10:17:14