html - 数据加载时的水平加载器

标签 html css

我正在尝试创建一个水平线的装载机。我的 html 是:

<div class="animated yt-loader"></div>

我的 CSS 是:

body {
  margin: 0;
}
.animated {
    -webkit-animation-duration: 10s;
    animation-duration: 10s;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-user-select: none;
}

.yt-loader {
    -webkit-animation-name: horizontalProgressBar;
    animation-name: horizontalProgressBar;
    -webkit-animation-timing-function: ease;
    animation-timing-function: ease;
    background: #ef534e;
    height: 3px;
    left: 0;
    top: 0;
    width: 0%;
    z-index: 9999;
    position:relative;
}

.yt-loader:after{
  display: block;
  position: absolute;
  content:'';
  right: 0px;
  width: 100px;
  height: 100%;
  box-shadow: #ef534e 1px 0 6px 1px;
  opacity: 0.5;
}
@keyframes horizontalProgressBar
{
    0%   {width: 0%;}
    20%  {width: 10%;}
    30%  {width: 15%;}
    40%  {width: 18%;}
    50%  {width: 20%;}
    60%  {width: 22%;}
    100% {width: 100%;}
}

但是像这样我无法通过数据加载来做到这一点。我需要添加一些延迟或其他任何东西,以便在数据加载 3 秒或 4 秒后,线宽增加 100%。

最佳答案

先生,

您必须在 Animated 类中更改动画持续时间

-webkit-animation-duration: 2s;
    animation-duration: 2s;

DEMO HERE

关于html - 数据加载时的水平加载器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39874779/

相关文章:

css - 使用CSS将div垂直对齐到div

javascript - 如何在着陆页菜单上制作 jQuery 从上到下滚动和从下到上慢速动画

css - 我无法将 div 的内容居中

html - 如何将条件格式添加到 CSS 中的列表项

html - 尝试将文本与图像对齐

javascript - 将带有类 ID 和图像的 div 添加到容器

php - 如何通过 id 从 html 元素中提取文本并分配给 php 变量?

javascript - 表单提交上的 CSS/JQuery/Angular 转换

javascript - Jquery 帮助分页器和显示元素。

css - 为什么我的 React 组件的 CSS 没有动态更新?