最後のnth-childで停止するようにクロスフェードアニメーションを取得するのに少し問題があります。私はアニメーション塗りつぶしモードを認識しています:転送は、動作しないようです(私は初期のクロスフェード宣言のように別の場所に置いてみました)最後のnth-childでCSSアニメーションを停止する方法css3
私のhtmlです:
<body>
<div class= "ad">
<div class="crossfade">
<img src="image1.jpg" alt="Image 1">
<img src="image2.png" alt="Image 2">
<img src="image3.png" alt="Image 3">
<img src="image4.png" alt="Image 4">
</div>
</div>
</body>
そして、私のCSSはここにある:
.crossfade > img {
width: 300px;
height: 250px;
position: absolute;
top: 0px;
left: 0px;
color: transparent;
opacity: 0;
z-index: 0;
animation-iteration-count:1;
-webkit-backface-visibility: hidden;
-webkit-animation-name: imageAnimation;
-webkit-animation: imageAnimation 43s linear 1 0s;
-moz-animation: imageAnimation 43s linear 1 0s;
-o-animation: imageAnimation 43 linear 1 0s;
-ms-animation: imageAnimation 43 linear 1 0s;
}
.crossfade > img:nth-child(1) {
-webkit-animation-delay: 1s;
-moz-animation-delay: 1s;
-o-animation-delay: 1s;
-ms-animation-delay: 1s;
animation-delay: 1s;
}
.crossfade > img:nth-child(2) {
-webkit-animation-delay: 7s;
-moz-animation-delay: 7s;
-o-animation-delay: 7s;
-ms-animation-delay: 7s;
animation-delay: 7s;
}
.crossfade > img:nth-child(3) {
-webkit-animation-delay: 14s;
-moz-animation-delay: 14s;
-o-animation-delay: 14s;
-ms-animation-delay: 14s;
animation-delay: 14s;
}
.crossfade > img:nth-child(4) {
-webkit-animation-delay: 21s;
-moz-animation-delay: 21s;
-o-animation-delay: 21s;
-ms-animation-delay: 21s;
animation-delay: 21s;
animation-fill-mode: forwards;
}
@-webkit-keyframes imageAnimation {
0%{ opacity:0;
-webkit-animation-timing-function: ease-in; }
8% { opacity: 1;
-webkit-animation-timing-function: ease-out; }
17% { opacity: 1}
25% { opacity: 0 }
100% { opacity: 0}
}
@-moz-keyframes imageAnimation {
0% { opacity: 0;
-moz-animation-timing-function: ease-in; }
8% { opacity: 1;
-moz-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0}
100% { opacity: 0 }
}
@-o-keyframes imageAnimation {
0% { opacity: 0;
-o-animation-timing-function: ease-in; }
8% { opacity: 1;
-o-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0 }
100% { opacity: 0 }
}
@-ms-keyframes imageAnimation {
0% { opacity: 0;
-ms-animation-timing-function: ease-in; }
8% { opacity: 1;
-ms-animation-timing-function: ease-out; }
17% { opacity: 1 }
25% { opacity: 0}
100% { opacity: 0 }
}
私は私が間違ってやっているか、私が欠けているものをかなりよく分かりません。前もって感謝します!
本当にありがとうございました!あなたは本当に簡単にそれに答えた、それは理にかなった。 (私はまだ少しcss3に新しいです)。私は、新しい「アニメーション」を宣言することを正しく理解していますか?毎回、個々の子供のアニメーションを「再起動」するようになるでしょうか? サイドの質問:私は現在チュートリアルに従っており、答えに-o-、-moz-、-webkit-を使用する必要がないことに気付きました。私の理解は、それらが異なるブラウザと互換性を持たせるために使用されていますが、あなたのバージョンは関係なく動作するようです。いつ私がそれらを使用するための特別なケースはありますか? :]再び感謝のヒープ。 –
@JessicaFooこの回答の解決策は、アニメーションを_restart_していない、それは私がすでに私の答え(2番目のサンプルをチェックしてください、これはまったく同じですが、より最適化されたものをチェックします)よりもパフォーマンスが低い4アニメーションを作成します。私はこのようにすることをお勧めしません。 – LGSon
@JessicaFooまた、接頭辞付きのプロパティの欠如は、それが理解されるように、古いブラウザでは必要とされていても機能しません。また、古いブラウザを持つWebサイトの訪問者にもアニメーションを参照してください。 – LGSon