【发布时间】:2021-07-14 16:50:35
【问题描述】:
我正在尝试使用 css 在幻灯片中插入 4 行文本。效果有效,但是当它到达第三张和第四张幻灯片时,文本重叠并且不会在正确的时间改变。
我该如何纠正这个问题?
这是我的代码:
.col-sm-12{width:100%;padding:15px;float:left;}
#textComAz .item-1, #textComAz .item-2, #textComAz .item-3, #textComAz .item-4 {position: absolute;display: block;top: 2em;width: 100%;font-size: 2em;animation-duration: 20s;animation-timing-function: ease-in-out;animation-iteration-count: infinite;text-align:center;}
#textComAz .item-1{animation-name: anim-1;}
#textComAz .item-2{animation-name: anim-2;}
#textComAz .item-3{animation-name: anim-3;}
#textComAz .item-4{animation-name: anim-4;}
@keyframes anim-1 {0%, 8.3% { left: -50%; opacity: 0; }8.3%,25% { left: 0%; opacity: 1; }33.33%, 100% { left: 25%; opacity: 0; }}
@keyframes anim-2 {0%, 33.33% { left: -50%; opacity: 0; }41.63%, 58.29% { left: 0%; opacity: 1; }66.66%, 100% { left: 25%; opacity: 0; }}
@keyframes anim-3 {0%, 55.55% { left: -50%; opacity: 0; }64.96%, 71.62% { left: 0%; opacity: 1; } 100% { left: 25%; opacity: 0; }}
@keyframes anim-4 {0%, 75.55% { left: -50%; opacity: 0; }84.96%, 91.62% { left: 0%; opacity: 1; }100% { left: 25%; opacity: 0; }}
<div id="textComAz" class="col-sm-12">
<p class="item-1">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor.</p>
<p class="item-2">Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium.</p>
<p class="item-3">But I must explain to you how all this mistaken idea of denouncing pleasure.</p>
<p class="item-4">NEW TEXT HERE.</p>
</div>
【问题讨论】: