gpt4 book ai didi

html - 使用 CSS3 的动画幻灯片

转载 作者:行者123 更新时间:2023-11-28 07:19:14 25 4
gpt4 key购买 nike

我想创建一个幻灯片,其中包含我使用 css3 创建的 3 个不同的动画。我的问题是我不能无限重复那些动画。

我有 3 个动画(第 3 个动画在第 2 个动画之上,第 2 个动画在第 1 个动画之上)。

<head>
<link rel="stylesheet" type="text/css" href="slideshow.css">
</head>
<body">
<div id="animation">
<img id="background1" src = "images/image1.png"/>
<img id="img2" src="images/image2.png"/>
<img id="img3" src="images/image3.png"/>
</div>

<div id="animation2" style = "position:absolute; top:0px; bottom:0px;">
<img id="background2" src ="images/image4.png"/>
<img id="img5" src="images/image5.png"/>
<img id="img6" src="images/image6.png"/>
</div>

<div id="animation3" style ="position:absolute; top:0px; bottom:0px;">
<img id="background3" src = "images/image7.png"/>
<img id="img8" src="images/image8.png"/>
</div>
<body>

使用 css3,我用上面的图像创建了一些动画(没有提供动画代码,因为我认为这与我的问题无关)。我现在想要的是创建一个幻灯片,使用那些永远不会结束的动画。

到目前为止我所拥有的是:

div#animation2 {
width:1130px;
height:222px;
overflow:hidden;

animation: slideshow1 20s;
animation-delay: 45s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
}

div#animation3 {
width:1130px;
height:222px;
overflow:hidden;

animation: slideshow2 20s;
animation-delay: 15s;
animation-fill-mode: forwards;
animation-iteration-count: 1;
}


@keyframes slideshow1 {
0% {opacity: 1;} 5% {opacity: 0;} 100% { opacity: 0; }
}

@keyframes slideshow2 {
0% {opacity: 1;} 5% {opacity: 0;} 100% { opacity: 0; }
}

所以总而言之,我希望 animation3 播放然后淡出,然后 animation2 播放然后淡出,animation1播放,然后动画3应该淡入,播放然后淡出等。

现在我只有一次幻灯片迭代,我想要无限次迭代。

我尝试将 animation-iteration-count: 设置为 infinite 但它无法正常工作。

最佳答案

你可以使用这样的东西 http://jsfiddle.net/qmhzs2kh/

* {
margin: 0;
padding: 0;
}
.pic-wrapper {
position: absolute;
width: 100%;
height: 100%;
overflow:hidden;
}

figure {
position: absolute;

top: 0;
left: 0;
width: 100%;
height: 100%;
opacity:0;
/*animation*/

animation: slideShow 24s linear infinite 0s;
-o-animation: slideShow 24s linear infinite 0s;
-moz-animation: slideShow 24s linear infinite 0s;
-webkit-animation: slideShow 24s linear infinite 0s;
}

.pic-1 {
opacity: 1;
z-index:-1;
background: url(http://www.rachelgallen.com/images/daisies.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

.pic-2 {
animation-delay: 6s;
-o-animation-delay: 6s;
-moz--animation-delay: 6s;
-webkit-animation-delay: 6s;
background: url(http://www.musicmatters.ie/images/5.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

.pic-3 {
animation-delay: 12s;
-o-animation-delay: 12s;
-moz--animation-delay: 12s;
-webkit-animation-delay: 12s;
background: url(http://www.musicmatters.ie/images/4.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}

.pic-4 {
animation-delay: 18s;
-o-animation-delay: 18s;
-moz--animation-delay: 18s;
-webkit-animation-delay: 18s;
background: url(http://www.musicmatters.ie/images/bara2.jpg) no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
/* keyframes*/

@keyframes slideShow {
0% {
opacity: 0;
transform:scale(1);
-ms-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
transform:scale(1.1);
-ms-transform:scale(1.1);
}
100% {
opacity: 0;
transform:scale(1);
-ms-transformm:scale(1);
}
}

@-o-keyframes slideShow {
0% {
opacity: 0;
-o-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
-o-transform:scale(1.1);
}
100% {
opacity: 0;
-o-transformm:scale(1);
}
}

@-moz-keyframes slideShow {
0% {
opacity: 0;
-moz-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
-moz-transform:scale(1.1);
}
100% {
opacity: 0;
-moz-transformm:scale(1);
}
}

@-webkit-keyframes slideShow {
0% {
opacity: 0;
-webkit-transform:scale(1);
}
4% {
opacity: 1
}
24% {
opacity: 1;
}
28% {
opacity: 0;
-webkit-transform:scale(1.1);
}
100% {
opacity: 0;
-webkit-transformm:scale(1);
}
}
<div class="pic-wrapper">
<figure class="pic-1"></figure>
<figure class="pic-2"></figure>
<figure class="pic-3"></figure>
<figure class="pic-4"></figure>
</div>

关于html - 使用 CSS3 的动画幻灯片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32178999/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com