斜めのグラデーションの背景を作成し、キーフレームタイマーの左端から右端までスライドできます。あなたのCSSファイルに以下を追加し、HTML要素に "shimmer"クラスを追加します。私は、キーフレームのbackground-position-x
プロパティの大きい番号と、CSSクラスのanimation
プロパティのアニメーション速度(現在は8秒)の組み合わせを使用して、アニメーション速度で試しました。
@keyframes shimmerBackground {
0% {background-position:-5000px 0}
100% {background-position:5000px 0}
}
.shimmer
{
background-image: -moz-linear-gradient(160deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0) 25%, rgba(255,255,255,0.85) 60%, rgba(255,255,255,0) 100%);
background-image: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0)), color-stop(25%,rgba(255,255,255,0)), color-stop(60%,rgba(255,255,255,0.85)), color-stop(100%,rgba(255,255,255,0)));
background-image: -webkit-linear-gradient(160deg, rgba(255,255,255,0) 0%,rgba(255,255,255,0) 25%,rgba(255,255,255,0.85) 60%,rgba(255,255,255,0) 100%);
background-image: -o-linear-gradient(160deg, rgba(255,255,255,0) 0%,rgba(255,255,255,0) 25%,rgba(255,255,255,0.85) 60%,rgba(255,255,255,0) 100%);
background-image: -ms-linear-gradient(160deg, rgba(255,255,255,0) 0%,rgba(255,255,255,0) 25%,rgba(255,255,255,0.85) 60%,rgba(255,255,255,0) 100%);
background-image: linear-gradient(160deg, rgba(255,255,255,0) 0%,rgba(255,255,255,0) 25%,rgba(255,255,255,0.85) 60%,rgba(255,255,255,0) 100%);
background-repeat: repeat-y;
background-position:-5000px 0;
animation: shimmerBackground 8s linear infinite;
}
キーフレームにもっと多くのステップを使用することをお勧めします。そうすることで、各ステップ/イテレーションで速度と色を変更することができます – LGSon