简体   繁体   English

关键帧动画无法在Moz和

[英]Keyframes animation not working on element of :hover in moz and

I ran into a problem where I want to animate some text inside a button on :hover. 我遇到了一个问题:我想在:hover上的按钮内设置一些文本的动画。 To target the text of the button I wrapped it inside a span element and target it like this: 为了定位按钮的文本,我将其包裹在span元素内,并按如下所示定位它:

button:hover span{
  animation:...
}

This works nicely in chrome, but fails in firefox and safari. 这在chrome中效果很好,但在Firefox和safari中不起作用。 It seems that the browsers don't support animating children of :hover which seems very weird. 似乎浏览器不支持:hover的动画子级,这似乎很奇怪。 Does anyone know the cause of this? 有人知道原因吗?

I'm attaching a link with the particular use case on codepen. 我在Codepen上附加了具有特定用例的链接。 http://codepen.io/JonasB/pen/cded300cb982d592b9db4cb0da2191d8 http://codepen.io/JonasB/pen/cded300cb982d592b9db4cb0da2191d8

It's due to the fact that the span is an inline element, adding property of display: inline-block fixes the issue. 这是由于span是一个内联元素,因此增加了display属性:inline-block解决了该问题。

This thread explains in more detail: Why can't inline elements be transformed? 该线程更详细地解释: 为什么不能转换内联元素?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM