gpt4 book ai didi

jquery - 淡出 CSS3 动画

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

这个想法是在您停止悬停 .item 之后动画本身淡出。 (不是整个元素)。

我尝试了以下 CSS:

.item{
box-shadow: 2px 2px 6px rgba(0,0,0,.5);
-webkit-transition: -webkit-animation 1s;
-webkit-animation: none;
}

.item:hover{
-webkit-animation: party_nav_alt2 1s infinite linear;
}

@-webkit-keyframes party_nav_alt2 {
0% {box-shadow: 0 0 8px 3px red;}
20% {box-shadow: 0 0 8px 3px yellow;}
40% {box-shadow: 0 0 8px 3px cyan;}
60% {box-shadow: 0 0 8px 3px #7700ff;}
80% {box-shadow: 0 0 8px 3px white;}
100% {box-shadow: 0 0 8px 3px red;}
}

但是没有用。

也欢迎使用 jQuery 解决方案。

编辑:下面是一个演示,看看我的意思。它具有效果,但总是以红色淡出:

jsFiddle

编辑 2:This is the effect我正在寻找的。

最佳答案

目前我认为如果不添加另一个元素这是不可能的。

但是如果你愿意添加另一个(不可见的)元素,你可以做 something like this ,它会切换与悬停动画阴影相同大小和位置的元素的不透明度

.item{
height: 100px;
width: 100px;
background: gray;
}
.animation {
box-shadow: 2px 2px 6px rgba(0,0,0,.5);
-webkit-transition: -webkit-animation 1s linear ease-out;
-webkit-animation: none;
transition: all 0s ease-out;
width:100%;
height:100%;
background:transparent;
transition: all 1s ease-in;
-webkit-animation: party_nav_alt2 1s infinite linear;
opacity:0;
}
.animation:hover{
opacity:1;
}

关于jquery - 淡出 CSS3 动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18858818/

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