.circle(@w, @h, @len, @i:0) when (@i < @len) {
@x: round(@i * 100 / (@len), 2); // 当前百分比
@selector: e(
"@{x}%"
); // 使用 less e 函数变为选择器,注意!!直接套用或者使用 percentage 函数无法识别;当前百分比进度
@unit: @h / (@len);
@top: -@i * @unit;
@left: 0;
@{selector} {
background-position: @left * @rex @top * @rex; // 修改图片定位
}
.circle(@w, @h, @len, (@i + 1));
}
@keyframes animat {
.circle(72, 720, 10);
}
.animate_div {
animation: animat 1.5s steps(1, start);
}
Less动画实现百分比加载
本文介绍了一种使用Less预处理器实现的动画效果,通过递归调用和百分比计算,实现了动态的背景图片定位,从而达到加载进度的视觉效果。代码中详细展示了如何设置动画关键帧,以及如何应用动画到指定的div元素上。
1032

被折叠的 条评论
为什么被折叠?



