gpt4 book ai didi

html - 尝试显示 6 张幻灯片时,CSS 中的 slider 不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 01:16:21 25 4
gpt4 key购买 nike

我正在尝试从我发现的 codepen 中改编一支笔,但它似乎不起作用。这支笔是一个带有 3 张幻灯片的文本 slider ,我的目标是让它与 6 张幻灯片一起使用。
原来的codepen是this
我的笔是this

我认为的问题是我的代码中的百分比错误。我的 6 张幻灯片的代码是

@keyframes anim-1 {
0%,
4.15% {
left: -100%;
opacity: 0;
}
4.15%,
12.45% {
left: 25%;
opacity: 1;
}
16.66%,
100% {
left: 110%;
opacity: 0;
}
}

@keyframes anim-2 {
0%,
16.66% {
left: -100%;
opacity: 0;
}
20.75%,
29.17% {
left: 25%;
opacity: 1;
}
33.32%,
100% {
left: 110%;
opacity: 0;
}
}

@keyframes anim-3 {
0%,
33.32% {
left: -100%;
opacity: 0;
}
37.47%,
45.83% {
left: 25%;
opacity: 1;
}
49.98%,
100% {
left: 110%;
opacity: 0;
}
}

@keyframes anim-4 {
0%,
49.98% {
left: -100%;
opacity: 0;
}
54.13%,
62.43% {
left: 25%;
opacity: 1;
}
66.58%,
100% {
left: 110%;
opacity: 0;
}
}

@keyframes anim-5 {
0%,
66.58% {
left: -100%;
opacity: 0;
}
70.73%,
79.03% {
left: 25%;
opacity: 1;
}
83.18%,
100% {
left: 110%;
opacity: 0;
}
}

@keyframes anim-6 {
0%,
83.18% {
left: -100%;
opacity: 0;
}
87.33%,
95.85% {
left: 25%;
opacity: 1;
}
100% {
left: 110%;
opacity: 0;
}
}

我弄乱了这篇文章中的缩进,但在 codepen 中一切都应该更清楚。
我不认为我犯了任何错别字,而且我仍在思考可能导致这种情况的原因。

最佳答案

在您的 CSS 中,您没有使用逗号分隔不同的类。添加这些,它将起作用。

您的代码

.item-1, 
.item-2,
.item-3
.item-4
.item-5
.item-6 {
...

修复

.item-1, 
.item-2,
.item-3,
.item-4,
.item-5,
.item-6 {
...

@import url(https://fonts.googleapis.com/css?family=Open+Sans:600);

body {
font-family: 'Open Sans', 'sans-serif';
color: #cecece;
background: #222;
overflow: hidden;
}

.item-1,
.item-2,
.item-3,
.item-4,
.item-5,
.item-6{
position: absolute;
display: block;
top: 2em;

width: 60%;

font-size: 2em;

animation-duration: 20s;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}

.item-1{
animation-name: anim-1;
}

.item-2{
animation-name: anim-2;
}

.item-3{
animation-name: anim-3;
}

.item-4{
animation-name: anim-4;
}

.item-5{
animation-name: anim-5;
}

.item-6{
animation-name: anim-6;
}

@keyframes anim-1 {
0%, 4.15% { left: -100%; opacity: 0; }
4.15%, 12.45% { left: 25%; opacity: 1; }
16.66%, 100% { left: 110%; opacity: 0; }
}

@keyframes anim-2 {
0%, 16.66% { left: -100%; opacity: 0; }
20.75%, 29.17% { left: 25%; opacity: 1; }
33.32%, 100% { left: 110%; opacity: 0; }
}

@keyframes anim-3 {
0%, 33.32% { left: -100%; opacity: 0; }
37.47%, 45.83% { left: 25%; opacity: 1; }
49.98%, 100% { left: 110%; opacity: 0; }
}

@keyframes anim-4 {
0%, 49.98% { left: -100%; opacity: 0; }
54.13%, 62.43% { left: 25%; opacity: 1; }
66.58%, 100% { left: 110%; opacity: 0; }
}

@keyframes anim-5 {
0%, 66.58% { left: -100%; opacity: 0; }
70.73%, 79.03% { left: 25%; opacity: 1; }
83.18%, 100% { left: 110%; opacity: 0; }
}

@keyframes anim-6 {
0%, 83.18% { left: -100%; opacity: 0; }
87.33%, 95.85% { left: 25%; opacity: 1; }
100% { left: 110%; opacity: 0; }
}
<p class="item-1">This is your last chance. After this, there is no turning back.</p>

<p class="item-2">You take the blue pill - the story ends, you wake up in your bed and believe whatever you want to believe.</p>

<p class="item-3">You take the red pill - you stay in Wonderland and I show you how deep the rabbit-hole goes.</p>

<p class="item-4">You take the red pill - you stay in Wonderland and I show you how deep the rabbit-hole goes.</p>

<p class="item-5">You take the red pill - you stay in Wonderland and I show you how deep the rabbit-hole goes.</p>

<p class="item-6">You take the red pill - you stay in Wonderland and I show you how deep the rabbit-hole goes.</p>

JSFiddle

关于html - 尝试显示 6 张幻灯片时,CSS 中的 slider 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50047107/

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