HTML& CSS进度条最终不会停止

时间:2017-07-04 11:08:59

标签: html css animation

我创建了这个进度条,但我无法在最后停止它。目前它停止在70%并被清除。有任何想法吗?是否有任何类型的动画设置可以将其停止在100%?



.wrap {
  background-color: #f2f2f2;
  height: 10px;
  width: 400px;
  margin: 0 auto;
  position: relative;
  top: 20px;
  margin-bottom: 20px;
}

.bar {
  background: #ffcc00;
  height: 10px;
  width: 0%;
}

.animating {
  -webkit-animation: progress 3s ;
}

@-webkit-keyframes progress {
  0% {
    width: 0%;
  }
  100% {
    width: 70%;
  }
}

<div class="wrap">
  <div class="bar animating"></div>
</div>
&#13;
&#13;
&#13;

3 个答案:

答案 0 :(得分:4)

animation-fill-mode: forwards;-webkit-animation: progress 3s forwards;

答案 1 :(得分:1)

尝试使用100%:

@-webkit-keyframes progress {
  0% {
    width: 0%;
  }
  100% {
    width: 70%; /* edit to 100% */
  }
}

答案 2 :(得分:0)

花式版

  .wrap {
  background-color: #f2f2f2;
  height: 10px;
  width: 400px;
  margin: 0 auto;
  position: relative;
  top: 20px;
  margin-bottom: 20px;
}

.wrap div {
  background-color: #ffcc00;
  height: 10px;
  width: 0%;
  border-radius: 5px;
  animation: loadbar 3s;
  -webkit-animation: loadbar 3s;
  -webkit-animation-fill-mode: forwards;
  animation-fill-mode: forwards;
}

@-webkit-keyframes loadbar {
  0% {
    width: 0%;
  }
  100% {
    width: 100%;
  }
  @keyframes loadbar {
    0% {
      width: 0%;
    }
    100% {
      width: 100%;
    }
  }
<div class="wrap">
  <div class="bar animating"></div>
</div>