只是尝试加载栏。主要问题是,一旦每个柱完成迭代,它需要在最后一个柱的顶部重新开始。我是通过一些hacky JS做到的,但也许有一种更聪明的方法来使用纯CSS吗?
HTML
<div class="loading-bar">
<div class="bar"><div class="bar-inner"></div></div>
<div class="bar"><div class="bar-inner"></div></div>
</div>
SCSS
.loading-bar {
clear: both;
height: 12px;
width: 100%;
position: relative;
.bar {
margin: 0 auto;
height: 12px;
position: absolute;
top: 0;
left: 0;
width: 100%;
text-align: center;
z-index: 0;
.bar-inner {
margin: 0 auto;
width: 0;
height: 12px;
-webkit-animation-name: loadbars;
-webkit-animation-duration: 1s;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: ease-in-out;
}
&:nth-child(1) .bar-inner {
background: gray;
}
&:nth-child(2) .bar-inner {
background: blue;
-webkit-animation-delay: 0.5s;
}
}
}
@-webkit-keyframes loadbars {
0% { width: 0; }
50% { width: 100%; }
100% { width: 100%; }
}
JS
var bars = $(".bar-inner");
var zindex = 1;
var listener = function () {
zindex++;
$(this).parent().css("z-index", zindex);
};
bars.on("webkitAnimationIteration", listener);
演示: http://jsfiddle.net/18uqrtxo/
我已经更新了演示,以显示带有4个条形图的纯CSS,只是为了好玩。