ユーザーがページの最初のセクションをスクロールしたときにフェードインしたいヘッダーがあります。次のように不透明度 1 に変化する不透明度 0 の div を使用します。
$(window).scroll(function () {
// If the scroll position is past the 1st section...
if ($('body').scrollTop() > 500) {
$('#ribbon').css('opacity', 1);
} else {
$('#ribbon').css('opacity', 0);
}
});
fadeIn()
これは正常に機能しますが、またはを使用して不透明度をアニメーション化しようとするとanimate()
、動作が停止し、div でフェードインしません。