cssを使用して3枚の画像の間でクロスフェードを実行しようとしています。複数画像間のクロスフェードCSS
私は@keyframesに新しいですので、動作させるには問題があります。以下は
は、HTMLとCSSのコードスニペットです:
のindex.html:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="cf">
<img class="bottom" src="assets/1.png" />
<img class="top" src="assets/2.png" />
<img class="bottom" src="assets/3.png">
</div>
</body>
</html>
のstyle.css:今
#cf {
position: relative;
height: auto;
width: auto;
margin: 0 auto;
}
#cf img {
position: absolute;
left: 0;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
#cf img {
animation-name: cf3FadeInOut;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
animation-duration: 6s;
animation-direction: alternate;
}
#cf img:nth-of-type(1) {
animation-delay: 4s;
}
#cf img:nth-of-type(2) {
animation-delay: 2s;
}
#cf img:nth-of-type(3) {
animation-delay: 0;
}
@keyframes cf3FadeInOut {
0% {
opacity: 1;
}
17% {
opacity: 1;
}
25% {
opacity: 0;
}
92% {
opacity: 0;
}
100% {
opacity: 1;
}
}
は、アニメーションは、奇妙な演技から点滅しています1つの画像を別の画像に、ランダムなアニメーション時に表示する。
それがうまくいった! imgトランジション間の時間をどのように増やすのですか?彼らはちょっと速く切り替わります。 – GreetingsFriend
時間を単に変更する - 私はそれに応じてそれを答えに加えました。 – Christoph
バックグラウンドの背景画像が表示されることがあります。私はそれを止めることができますか? – GreetingsFriend