css - 如何编写CSS关键帧来确定 Material 设计进度条

标签 css material-design

我想制作一个不确定的进度条,如 material design (第二个)在网页中使用 CSS3。任何人都可以分享必要的 CSS 魔法吗?我希望它的行为与视频中的完全相同,所以一端正在加速,而另一端正在减速,直到它们切换。

我找不到任何可用这种方式工作的现有示例。

最佳答案

I found a good example by Stefano on CodePen :

// Android Material Loading animation with pure css. 
// Author: Stefano Ferrara http://androidpc.it/
// Forked from https://codepen.io/chofoo/pen/Abril
// Author: Simon Clavey https://simonclavey.co.uk/
body{
  background:#ffffff;
  margin:50px 300px;
}

.slider{
  position:absolute;
  width:1000px;
  height:5px;
  overflow-x: hidden;
}

.line{
  position:absolute;
  opacity: 0.4;
  background:#4a8df8;
  width:150%;
  height:5px;
}

.subline{
  position:absolute;
  background:#4a8df8;
  height:5px; 
}
.inc{
  animation: increase 2s infinite;
}
.dec{
  animation: decrease 2s 0.5s infinite;
}

@keyframes increase {
   from { left: -5%; width: 5%; }
   to { left: 130%; width: 100%;}
}
@keyframes decrease {
   from { left: -80%; width: 80%; }
   to { left: 110%; width: 10%;}
}
<div class="slider">
  <div class="line"></div>
  <div class="subline inc"></div>
  <div class="subline dec"></div>
</div>

许可证:

Copyright (c) 2016 by Stefano (https://codepen.io/shalimano/pen/wBmNGJ)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

关于css - 如何编写CSS关键帧来确定 Material 设计进度条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34773266/

相关文章:

angularjs - 如何一起使用 ng-polymer-elements 、 angularjs 和 requirejs?

android - Material Design 应用程序需要状态栏和工具栏之间的阴影吗?

javascript - 在表格内显示/隐藏 tbody 标签

html - 如何在表格单元格内正确垂直对齐图像+文本

javascript - 使用 Bootstrap Material 设计为文本区域的所有边框添加渐变

javascript - 如何使用具有 Angular/ Material 设计的底板?

android - 启动时应用程序崩溃( Material 主题问题)

html - 水平垂直居中绝对定位元素

javascript - 如何在状态之间为图像设置动画

javascript - Bootstrap/CSS 输入表单不居中