【发布时间】:2015-12-08 23:54:46
【问题描述】:
当我在元素内移动鼠标但光标(鼠标指针)始终在原始元素内时,我想保持动画持续到最后而不是重新启动。有可能吗?
我的代码是:Fiddle Demo
.container{
height: 200px;
width: 100px;
}
.conteiner li{
display: inline-block; float: left;
text-align: center;
height: 100%; width: auto;
background-color: white;
}
.conteiner li a{
position: relative; display: flex;
align-items: center;
justify-content: center;
padding: 0 2em 0 2em;
border: solid 1px black;
}
.conteiner li:HOVER{
animation-name: menu_header_li;
animation-duration: 5s;
animation-timing-function: linear;
}
@keyframes menu_header_li {
0%{
transform: rotateY(0deg);
background-color: white;
}
50%{
transform: rotateY(90deg);
background-color: red;
}
100%{
transform: rotateY(0deg);
background-color: white;
}
}
如果我在元素上移动鼠标,动画会重新开始,我不明白为什么。
【问题讨论】:
-
提前感谢大家
-
您是指鼠标移动还是快速鼠标移入、移出、移入组合?如果是前者,那么我看不到任何重启。如果是后者,那么纯 CSS 是做不到的。
-
mouse-in mouse-out,但在开始的 100px 中,不在页面的任何部分...当我将鼠标 51px 移动到 50px 时限制为 50px,动画重新开始
-
我没听懂,但你的问题听起来像是 stackoverflow.com/questions/31806649/… 的重复。仅当
hover开启时才会添加动画。当您不再悬停元素(鼠标移出)时,动画将不再适用,因此它会在您再次悬停时恢复到原始位置并重新启动。 -
但实际上我总是在原始元素的悬停(鼠标进入)中。
标签: css css-animations css-transforms