以下は、背景として機能している画像要素です。位置は絶対的であり、z-index も低いため、残りのコンテンツの背後に留まります。
<img src="day-sky.jpg" id="background" />
以下の秒は、1 分間の秒数を表しています。これは単なるテスト目的ですが、秒が 30 秒未満の場合は 1 つの背景画像を、30 秒を超える場合は別の画像を使用したいと考えています。可能であれば、トランジションは次の画像への素晴らしいフェードになります。
これを行う方法を探していましたが、良い方法が思いつきませんでした。何かご意見は?
function changeBackground() {
if (secs > 30) {
//have one background
}
else {
//have a different background
}
}