анимированный текст\заголовок

by Denis Tverdokhlebov

HTML

<!DOCTYPE html>
<html lang="en">

  <head>
    <title>Text-reveal animation</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" rel="stylesheet">
  </head>

  <body>
    <div id="buttons">
      <button id="refresh">Run again</button><a class="postlink" href="https://codepen.io/owlypixel/post/text-reveal-animation-tutorial">Read the post</a>
    </div>
    <div id="app">
      <div class="ui-slide-in">
        <div class="text-wrapper">
          <div class="line"><span class="black">Супер текст,</span> <span class="black yellow">выделенный</span> <span class="thin">с другим курсивом,</span></div>
          <div class="line">шириной <span class="thin">и</span> <span class="yellow">цветом</span> ...</div>
        </div>
      </div>
    </div>
  </body>

</html>

CSS

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
}

*,
*:before,
*:after {
  box-sizing: border-box;
}

body {
  display: flex;
  align-items: center;
  justify-content: left;
  background: url(https://raw.githubusercontent.com/owlypixel/Text_reveal_animation/master/Project-snapshots/1-starter/images/rabbit_bg.png);
  background-size: cover;
  font: 36px/1.2 'Open Sans', sans-serif;
}

#app {
  position: relative;
}

#app:after {
  display: block;
  content: '';
  position: absolute;
  border-left: 10px solid #FFCA00;
  left: 1.528em;
  top:54%;
  width: 0.278em;
  height: 80%;
  transform: translateY(-50%) scaleY(0);
  animation: left-border-expand .8s;
  animation-fill-mode: forwards;
  transform-origin: 50% 50%;
}

.ui-slide-in {
  width: 720px;
  height: 165px;
  background-color: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0.2em 1em rgba(0, 0, 0, 0.3);
  color: #fff;
  padding: 20px 20px 20px 65px;
  animation: ui-slide-in-move 1.25s;
  animation-timing-function: cubic-bezier(0.03, 0.98, 0.5, 1);
  transform-origin: left center;
}

.ui-slide-in .text-wrapper {
  text-transform: uppercase;
  padding-left: 0.556em;
  overflow: hidden;
}

.line {
  opacity: 0;
  animation: word-line-slide-out .25s forwards;
  animation-timing-function: ease-out;
}

.line:nth-child(1n) {
  animation-delay: 0.5s;
}

.line:nth-child(2n) {
  animation-delay: 0.75s;
}

.line span {
  display: inline-block;
  height: 43.2px;
}

.yellow {
  color: #FFCA00;
}

.black {
  font-weight: 800;
}

.thin {
  font-weight: 300;
}

@keyframes ui-slide-in-move {
  0% {
    transform: scaleX(0);
  }
  100% {
    transform: scaleX(100%);
  }
}

@keyframes left-border-expand {
  100% {
    transform: translateY(-50%) scaleY(1);
  }
}

@keyframes word-line-slide-out {
  0% {
    transform: translateX(-10vw);
    opacity: 0;
  }
  100% {
    transform: translateX(0vw);
    opacity: 1;
  }
}

#buttons {
  display: flex;
  position: absolute;
  top: 5%;
  left: 50%;
  transform:...

JavaScript

// this is a simple hack to restart css animation

var refresh_button = document.querySelector("#refresh");
refresh_button.addEventListener('click', function() {
  var app = document.querySelector("#app");
  var newone = app.cloneNode(true);
  app.parentNode.replaceChild(newone, app);
})