gpt4 book ai didi

animation - 如何在一个元素上有多个 CSS 过渡?

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

这是一个非常简单的问题,但我找不到关于 CSS 过渡属性的非常好的文档。这是 CSS 片段:

    .nav a
{
text-transform:uppercase;
text-decoration:none;
color:#d3d3d3;
line-height:1.5 em;
font-size:.8em;
display:block;
text-align:center;
text-shadow: 0 -1.5em 0 rgba(255, 255, 255, 0.15);
-webkit-transition: color .2s linear;
-moz-transition: color .2s linear;
-o-transition: color .2s linear;
transition: color .2s linear;
-webkit-transition: text-shadow .2s linear;
-moz-transition: text-shadow .2s linear;
-o-transition: text-shadow .2s linear;
transition: text-shadow .2s linear;
}

.nav a:hover
{
color:#F7931E;
text-shadow: 0 1.5em 0 rgba(247, 147, 30, 0.15);
}

如您所见,过渡属性相互覆盖。就目前而言,文本阴影将具有动画效果,但颜色不会。我如何让它们同时动画?感谢您的回答。

最佳答案

在所有支持转换的浏览器中,转换属性都是逗号分隔的:

.nav a {
transition: color .2s, text-shadow .2s;
}

ease 是默认的计时函数,因此您不必指定它。如果你真的想要 linear,你需要指定它:

transition: color .2s linear, text-shadow .2s linear;

这开始变得重复,所以如果您要在多个属性中使用相同的时间和计时函数,最好继续使用各种 transition-* 属性而不是简写:

transition-property: color, text-shadow;
transition-duration: .2s;
transition-timing-function: linear;

关于animation - 如何在一个元素上有多个 CSS 过渡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56722509/

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