如何显示前三个徽标等待几秒钟并无限循环显示接下来的三个徽标?
How to display the first three logos wait for some second and display next three logos with infinite loop?
我现在有 9 个徽标,我正在按列表顺序显示该徽标。现在我正在做的是,我必须显示前 3 个徽标并等待几秒钟,然后隐藏这 3 个徽标并再次显示接下来的 3 个徽标等待几秒钟,然后显示接下来的 3 个徽标。我需要无限这个。
例如:
On the page load display first 3 logo
1 2 3
//wait for the second
1 2 3 // hide this
4 5 6 // display this
7 8 9 // hide this
//wait for second
1 2 3 // hide this
4 5 6 // hide this
7 8 9 // display this
// wait for second
1 2 3 // display this
4 5 6 // hide this
7 8 9 // hide this
I need infinite.
我试过这段代码,但它不起作用。
ul {
list-style: none;
width: 100%;
position: relative;
}
ul li {
display: inline-block;
width: 33%;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
opacity: 0;
animation-name: fadeIn;
}
ul li img {
width: 250px;
}
/*Animated Logos*/
@keyframes fadeIn {
0% {
opacity: 0;
}
6% {
opacity: 1;
}
27% {
opacity: 1;
}
33% {
opacity: 0;
}
}
.row--animated li:nth-of-type(-n+3) {
animation-duration: 4s;
}
.row--animated li:nth-child(4),
.row--animated li:nth-child(5),
.row--animated li:nth-child(6) {
animation-duration: 6s;
}
.row--animated li:nth-last-child(-n+3) {
animation-duration: 8s;
/*position: absolute;*/
}
<div class="row--animated">
<ul>
<li><img src="//placehold.it/450x280?text=Image 1" /></li>
<li><img src="//placehold.it/450x280?text=Image 2" /></li>
<li><img src="//placehold.it/450x280?text=Image 3" /></li>
<li><img src="//placehold.it/450x280?text=Image 4" /></li>
<li><img src="//placehold.it/450x280?text=Image 5" /></li>
<li><img src="//placehold.it/450x280?text=Image 6" /></li>
<li><img src="//placehold.it/450x280?text=Image 7" /></li>
<li><img src="//placehold.it/450x280?text=Image 8" /></li>
<li><img src="//placehold.it/450x280?text=Image 9" /></li>
</ul>
</div>
你能帮我解决这个问题吗?
Update:这个片段就是我想你想要的,请注意我稍微更改了 HTML 以便我可以操纵元素的大小和显示,已实现只有 CSS3,深受此 codepen:
启发
.slider {
width: 900px;
margin: 0 auto;
}
.slide {
position: absolute;
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 10px;
}
.slide img {
width: 100;
height: auto;
}
.slide1 {
animation: fade 8s infinite;
-webkit-animation: fade 8s infinite;
}
.slide2 {
animation: fade2 8s infinite;
-webkit-animation: fade2 8s infinite;
}
.slide3 {
animation: fade3 8s infinite;
-webkit-animation: fade3 8s infinite;
}
@keyframes fade {
0% {
opacity: 1;
}
33.333% {
opacity: 0;
}
66.666% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade2 {
0% {
opacity: 0;
}
33.333% {
opacity: 1;
}
66.666% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@keyframes fade3 {
0% {
opacity: 0;
}
33.333% {
opacity: 0;
}
66.666% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class='slider'>
<div class='slide slide1'>
<div class="container">
<img src="//placehold.it/300x280?text=Image 1" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 2" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 3" />
</div>
</div>
<div class='slide slide2'>
<div class="container">
<img src="//placehold.it/300x280?text=Image 4" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 5" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 6" />
</div>
</div>
<div class='slide slide3'>
<div class="container">
<img src="//placehold.it/300x280?text=Image 7" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 8" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 9" />
</div>
</div>
</div>
</body>
</html>
您可以使用 display-grid 强制将元素排成一行。
并且您可以使用动画的属性来获得这种效果,但是所有元素的动画持续时间应该相同;从一个到另一个的变化是延迟,使然后处于动画的不同阶段:
ul {
list-style: none;
width: 100%;
position: relative;
display: grid;
}
ul li {
display: inline-block;
width: 30%;
opacity: 0.2;
animation: fadeInSlow ease-in-out 6s infinite;
background-color: blue;
height: 50px;
grid-row: 1;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
6% {
opacity: 1;
}
27% {
opacity: 1;
}
33% {
opacity: 0;
}
}
@keyframes fadeInSlow {
0% {
opacity: 0;
}
12% {
opacity: 1;
}
21% {
opacity: 1;
}
33%, 100% {
opacity: 0;
}
}
li:nth-child(4),
li:nth-child(5),
li:nth-child(6) {
animation-delay: -4s;
}
li:nth-child(7),
li:nth-child(8),
li:nth-child(9) {
animation-delay: -2s;
}
li:nth-child(3n+1) {
grid-column: 1;
}
li:nth-child(3n+2) {
grid-column: 2;
}
li:nth-child(3n+3) {
grid-column: 3;
}
<div class="row--animated">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
</ul>
</div>
我现在有 9 个徽标,我正在按列表顺序显示该徽标。现在我正在做的是,我必须显示前 3 个徽标并等待几秒钟,然后隐藏这 3 个徽标并再次显示接下来的 3 个徽标等待几秒钟,然后显示接下来的 3 个徽标。我需要无限这个。
例如:
On the page load display first 3 logo
1 2 3
//wait for the second
1 2 3 // hide this
4 5 6 // display this
7 8 9 // hide this
//wait for second
1 2 3 // hide this
4 5 6 // hide this
7 8 9 // display this
// wait for second
1 2 3 // display this
4 5 6 // hide this
7 8 9 // hide this
I need infinite.
我试过这段代码,但它不起作用。
ul {
list-style: none;
width: 100%;
position: relative;
}
ul li {
display: inline-block;
width: 33%;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
opacity: 0;
animation-name: fadeIn;
}
ul li img {
width: 250px;
}
/*Animated Logos*/
@keyframes fadeIn {
0% {
opacity: 0;
}
6% {
opacity: 1;
}
27% {
opacity: 1;
}
33% {
opacity: 0;
}
}
.row--animated li:nth-of-type(-n+3) {
animation-duration: 4s;
}
.row--animated li:nth-child(4),
.row--animated li:nth-child(5),
.row--animated li:nth-child(6) {
animation-duration: 6s;
}
.row--animated li:nth-last-child(-n+3) {
animation-duration: 8s;
/*position: absolute;*/
}
<div class="row--animated">
<ul>
<li><img src="//placehold.it/450x280?text=Image 1" /></li>
<li><img src="//placehold.it/450x280?text=Image 2" /></li>
<li><img src="//placehold.it/450x280?text=Image 3" /></li>
<li><img src="//placehold.it/450x280?text=Image 4" /></li>
<li><img src="//placehold.it/450x280?text=Image 5" /></li>
<li><img src="//placehold.it/450x280?text=Image 6" /></li>
<li><img src="//placehold.it/450x280?text=Image 7" /></li>
<li><img src="//placehold.it/450x280?text=Image 8" /></li>
<li><img src="//placehold.it/450x280?text=Image 9" /></li>
</ul>
</div>
你能帮我解决这个问题吗?
Update:这个片段就是我想你想要的,请注意我稍微更改了 HTML 以便我可以操纵元素的大小和显示,已实现只有 CSS3,深受此 codepen:
启发.slider {
width: 900px;
margin: 0 auto;
}
.slide {
position: absolute;
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 10px;
}
.slide img {
width: 100;
height: auto;
}
.slide1 {
animation: fade 8s infinite;
-webkit-animation: fade 8s infinite;
}
.slide2 {
animation: fade2 8s infinite;
-webkit-animation: fade2 8s infinite;
}
.slide3 {
animation: fade3 8s infinite;
-webkit-animation: fade3 8s infinite;
}
@keyframes fade {
0% {
opacity: 1;
}
33.333% {
opacity: 0;
}
66.666% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes fade2 {
0% {
opacity: 0;
}
33.333% {
opacity: 1;
}
66.666% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@keyframes fade3 {
0% {
opacity: 0;
}
33.333% {
opacity: 0;
}
66.666% {
opacity: 1;
}
100% {
opacity: 0;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class='slider'>
<div class='slide slide1'>
<div class="container">
<img src="//placehold.it/300x280?text=Image 1" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 2" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 3" />
</div>
</div>
<div class='slide slide2'>
<div class="container">
<img src="//placehold.it/300x280?text=Image 4" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 5" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 6" />
</div>
</div>
<div class='slide slide3'>
<div class="container">
<img src="//placehold.it/300x280?text=Image 7" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 8" />
</div>
<div class="container">
<img src="//placehold.it/300x280?text=Image 9" />
</div>
</div>
</div>
</body>
</html>
您可以使用 display-grid 强制将元素排成一行。
并且您可以使用动画的属性来获得这种效果,但是所有元素的动画持续时间应该相同;从一个到另一个的变化是延迟,使然后处于动画的不同阶段:
ul {
list-style: none;
width: 100%;
position: relative;
display: grid;
}
ul li {
display: inline-block;
width: 30%;
opacity: 0.2;
animation: fadeInSlow ease-in-out 6s infinite;
background-color: blue;
height: 50px;
grid-row: 1;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
6% {
opacity: 1;
}
27% {
opacity: 1;
}
33% {
opacity: 0;
}
}
@keyframes fadeInSlow {
0% {
opacity: 0;
}
12% {
opacity: 1;
}
21% {
opacity: 1;
}
33%, 100% {
opacity: 0;
}
}
li:nth-child(4),
li:nth-child(5),
li:nth-child(6) {
animation-delay: -4s;
}
li:nth-child(7),
li:nth-child(8),
li:nth-child(9) {
animation-delay: -2s;
}
li:nth-child(3n+1) {
grid-column: 1;
}
li:nth-child(3n+2) {
grid-column: 2;
}
li:nth-child(3n+3) {
grid-column: 3;
}
<div class="row--animated">
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li>8</li>
<li>9</li>
</ul>
</div>