gpt4 book ai didi

html - CSS 不透明度过渡一次淡入一行

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

我正在尝试使用过渡来改变不透明度并依次淡出三行。我的页面上有一个带有 3 p 和强标签的 div,我试图在大约 2 秒后淡入每行,中间间隔 0.5 秒。这是我正在尝试的只有 div 和 css 的 fiddle 。我已经搜索了这个主题并尝试了 css 和 js 的一些变体,但无论我做什么,线条开始时都是完全可见的,但如果我通过检查器切换不透明度,它就会进出过渡(也没有延迟因为某些原因)。任何帮助将不胜感激,谢谢!

http://jsfiddle.net/7uR8z/5047/

<div class=".Index-gallery-item-content-body">  
<p>
<strong>Test Line 1</strong>
</p>

<p>
<strong>Line 2 Here</strong>
</p>

<p>
<strong>Awesome Line 3</strong>
</p>

</div>

CSS:

.Index-gallery-item-content-body p
{
opacity:0
}

.Index-gallery-item-content-body p:nth-child(1)
{
opacity:1;
transition-delay: 2.5s;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}

.Index-gallery-item-content-body p:nth-child(2)
{
opacity:1;
transition-delay: 3s;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-ou
}

.Index-gallery-item-content-body p:nth-child(3)
{
opacity:1;
transition-delay: 3.5s;
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-ms-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-ou
}

最佳答案

您正在寻找动画而不是过渡:

.Index-gallery-item-content-body p {
opacity: 0
}

.Index-gallery-item-content-body p:nth-child(1) {
animation: change 2s ease-in-out forwards;
}

.Index-gallery-item-content-body p:nth-child(2) {
animation: change 2s ease-in-out forwards;
animation-delay: 2.5s;
}

.Index-gallery-item-content-body p:nth-child(3) {
animation: change 2s ease-in-out forwards;
animation-delay: 5s;
}

@keyframes change {
to {
opacity: 1
}
}
<div class="Index-gallery-item-content-body">
<p>
<strong>Test Line 1</strong>
</p>
<p>
<strong>Line 2 Here</strong>
</p>
<p>
<strong>Awesome Line 3</strong>
</p>
</div>

关于html - CSS 不透明度过渡一次淡入一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52937103/

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