使用脉动环定时文本转换

时间:2018-05-03 13:12:12

标签: javascript html css animation

目标是让文本过渡到3个不同的单词。我希望它们与动画环同步(每两个环动画淡入和淡出后文本更改)我不确定设置环和文本的时间的最佳方法是什么 - 如果这样做的话使用javascript或CSS动画关键帧?下面是我的codepen和HTML / CSS的链接 Codepen - https://codepen.io/pizzapgh/pen/RygPQJ

body {
  background-color: gray;
}

#circles {
  width: 1000px;
  height: 1000px;
  display: inline-block;
  position: relative;
  margin: auto;
  border: 1px solid blue;
}

#circles div {
  position: absolute;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.5);
  width: 0;
  height: 0;
  opacity: 0;
  animation-name: growCircles;
  animation-duration: 8s;
  transition-timing-function: ease-out;
  animation-iteration-count: infinite;
}

#circles div:nth-child(1) {
  animation-delay: 0s;
}

#circles div:nth-child(2) {
  animation-delay: 1s;
}

#circles div:nth-child(3) {
  animation-delay: 2s;
}

#circles div:nth-child(4) {
  animation-delay: 3s;
}

#circles div:nth-child(5) {
  animation-delay: 4s;
}

#circles div:nth-child(6) {
  animation-delay: 5s;
}

@keyframes growCircles {
  0% {
    top: 500px;
    left: 500px;
  }
  20% {
    opacity: 0.5;
  }
  80% {
    opacity: 0;
    top: 0;
    left: 0;
    width: 1000px;
    height: 1000px;
  }
  100% {
    opacity: 0;
  }
}


/*================================
                  Text Transition
              ================================== */

#spin:after {
  content: "";
  animation: spin 5s ease-in infinite;
}

@keyframes spin {
  0% {
    content: "From The Classroom";
  }
  60% {
    content: "To the City";
  }
  100% {
    content: "To the World";
  }
}

h2 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  color: white;
  width: 500px;
  overflow: hidden;
  text-align: center;
  font-family: 'RockwellMT' !important;
}
<div class="circle-container">
  <div id="circles">
    <h2 id="spin"></h2>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
    <div></div>
  </div>
</div>

0 个答案:

没有答案