2枚の画像を重ね合わせて、jQueryを使って無限にスクロールさせようとしています。 CSSで画像をスクロールしてレイヤーを作成することはできますが、アニメーションは非常にぎこちなくなります。 jQueryを使用してイメージ上に無限の水平スクロールを作成し、アニメーションを滑らかに保つにはどうすればよいですか?これまでjQueryでイメージを無限に水平にスクロールする方法は?
マイコード:
CSS:
@keyframes animatedBackground {
from { background-position: 0 0; }
to { background-position: 100% 0; }
}
#animate-area {
width: 100vw;
height: 100vw;
background-image: url(http://oi64.tinypic.com/2r7ri29.jpg);
background-position: 0px 0px;
background-repeat: repeat-x;
animation: animatedBackground 135s linear infinite;
}
#animate-area2 {
width: 100vw;
height: 100vw;
background-image: url(http://oi67.tinypic.com/2niy905.jpg);
background-repeat: repeat-x;
position: relative;
animation: animatedBackground 80s linear infinite;
}
とHTML:
<div id="animate-area"></div>
<div id="animate-area2"></div>
、gaetanoM問題ではありません。問題は '%'を使うことです。この '%'は、背景サイズを指すのではなく、要素サイズを参照します。したがって、要素が背景と同じ幅を持つ場合にのみ動作します。これは解決するのは難しい問題です。あなたの背景をカットする方法を知っているなら、特定のw/h範囲の比率の中で 'background-size:cover'が動作します。 –
@AndreiGheorghiu情報ありがとうございました。とても貴重です。再度、感謝します – gaetanoM