【问题标题】:How i can remove flickering in this Facebook-like loader? [duplicate]我怎样才能消除这个类似 Facebook 的加载程序中的闪烁? [复制]
【发布时间】:2020-01-17 13:27:27
【问题描述】:

这是一个类似 Facebook 的加载器。我不知道为什么会闪烁。 我试过改变大小,这会影响闪烁,但我不明白怎么做。 有人可以帮我找出原因吗?

div{
width:600px;
height:100px;
}

.placeholder-waves {
    -webkit-animation-duration: 1.3s;
    animation-duration: 1.3s;
    -webkit-animation-fill-mode: forwards;
    animation-fill-mode: forwards;
    -webkit-animation-iteration-count: infinite;
    animation-iteration-count: infinite;
    -webkit-animation-name: wave;
    animation-name: wave;
    -webkit-animation-timing-function: linear;
    animation-timing-function: linear;
    -webkit-animation-delay: 0s;
    animation-delay: 0s;
    -webkit-animation-direction: normal;
    animation-direction: normal;
    background-size: 1200px 104px;
    background: #f6fbfb;
    background: #eeeeee;
    background: linear-gradient(to right, #eeeeee 4%, #dddddd 47%, #eeeeee 87%);
}

@keyframes wave {
  0% {
    background-position: -468px 0
  }
  100% {
    background-position: 468px 0
  }
}

@-webkit-keyframes wave {
  0% {
    background-position: -468px 0
  }
  100% {
    background-position: 468px 0
  }
}
<div class="placeholder-waves"></div>

【问题讨论】:

    标签: html css


    【解决方案1】:

    在您的关键帧中,您写道: background-position: -468px 0;

    当您的 div 长度为 600px 时,是否有理由使用 468px ?因为这就是导致跳跃的原因。由于 div,渐变是 600px 长。所以在任何地方都使用相同的长度(600px),它工作得很好:

    div{
    width:600px;
    height:100px;
    }
    
    .placeholder-waves {
        -webkit-animation-duration: 1.3s;
        animation-duration: 1.3s;
        -webkit-animation-fill-mode: forwards;
        animation-fill-mode: forwards;
        -webkit-animation-iteration-count: infinite;
        animation-iteration-count: infinite;
        -webkit-animation-name: wave;
        animation-name: wave;
        -webkit-animation-timing-function: linear;
        animation-timing-function: linear;
        -webkit-animation-delay: 0s;
        animation-delay: 0s;
        -webkit-animation-direction: normal;
        animation-direction: normal;
        background-size: 1200px 104px;
        background: #f6fbfb;
        background: #eeeeee;
        background: linear-gradient(to right, #eeeeee 4%, #dddddd 47%, #eeeeee 87%);
    }
    
    @keyframes wave {
      0% {
        background-position: -600px 0
      }
      100% {
        background-position: 600px 0
      }
    }
    
    @-webkit-keyframes wave {
      0% {
        background-position: -600px 0
      }
      100% {
        background-position: 600px 0
      }
    }
    <div class="placeholder-waves"></div>

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-03
    • 2021-04-17
    • 1970-01-01
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多