我想制作一个预加载器,当页面加载时,而不是根据加载的百分比调整 div 的宽度,我想根据加载的百分比更改 div 的背景颜色的饱和度。
老实说,我不介意我是否必须设置#fff,然后将该颜色淡化为红色,我只是不知道如何喜欢饱和度变化或加载百分比后褪色的颜色百分比。
这是我一直在尝试的:
JS
$("#preloader").each(function() {
$(this)
.data("origColor", $(this).backgroundColor())
.backgroundColor('#f4421a')
.animate({
backgroundColor: $(this).data("origColor")
}, 1200);
});
CSS
@-webkit-animation changeColor {
0% { background-color: $white; }
100% { background-color: $orange; }
}
.js div#preloader {
@include position(fixed, $z:9999);
width: 100%;
height: 100%;
overflow: visible;
background: $loading no-repeat center center, $header-bg-mobile repeat top left, lighten($black,70%);
-webkit-animation: changeColor 2s linear infinite;
}