<html>
<head>
<style type="text/css">
div#bg1 {
height: 159px;
width: 800px;
margin-left: auto;
margin-right: auto;
background-image: url('images/bg1.jpg');
background-repeat: no-repeat;
background-position:center center;
position: relative;
z-index: 3;
}
div#bg2 {
height: 159px;
width: 800px;
margin-left: auto;
margin-right: auto;
background-image: url('images/bg2.jpg');
background-repeat: no-repeat;
background-position:center center;
position: relative;
z-index: 2;
margin-top: -159px;
}
</style>
<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
function Animate_2()
{
$("div#bg1").animate({opacity: 100}, 2000);
$("div#bg2").animate({opacity: 0 }, 2000);
setTimeout(Animate_1, 5000);
}
function Animate_1()
{
$("div#bg1").animate({opacity: 0 }, 2000);
$("div#bg2").animate({opacity: 100}, 2000);
setTimeout(Animate_2, 5000);
}
$(function()
{
/* Start cycle */
setTimeout(Animate_1, 5000);
});
</script>
</head>
<body>
<div id="bg1"></div>
<div id="bg2"></div>
</body>
</html>
Animate_1()正常に動作しますが、Animate_2は()だけで不透明度をアニメーション化することなく、bg2.jpgが表示されますが発生しません。これは、IEとFirefoxで同じ..ですjqueryのアニメーションは
なぜこれは?>
同じ結果...まずアニメイトで結構です、二回目は、それだけですぐにアニメーションではなくなりますイメージを変更します。 –
私はあなたが何を意味するかを見ます。不透明度は、0〜100の尺度ではなく、0〜1の尺度です。アニメーション化していましたが、1/100の途中で完全に不透明でした。私は両方のコードサンプルを修正しました。 – Oli
それでした!ありがとうたくさん...後で私がとても愚かな気分になる。 –