简体   繁体   English

CSS3 3D动画无法使用:悬停属性

[英]CSS3 3D animation not working with :hover property

I'm not a web developer, but I was dabbling with 3D CSS transformations and animations and found that they didn't interact with :hover the way I hoped or expected. 我不是网络开发人员,但我正在涉及3D CSS转换和动画,并发现它们没有与之交互:按照我希望或预期的方式悬停。 I wasn't able to readily find any disclaimer that this is a known problem, so I'm wondering if I'm just doing something wrong. 我无法轻易找到任何关于这是一个已知问题的免责声明,所以我想知道我是否只是做错了什么。

To reproduce the problem simply, start from this demo 3D cube animation here: 要简单地重现问题,请从此演示3D立方体动画开始:

http://cssdeck.com/labs/simple-css3-3d-cube http://cssdeck.com/labs/simple-css3-3d-cube

Add this to the bottom of the style section: 将其添加到样式部分的底部:

#cube div:hover {
  background-color: white;
}

I'm looking at that, using Chrome. 我正在看着它,使用Chrome。 I was hoping that, as both the cube rotated and the cursor moved (or didn't) the front-facing side containing the cursor would have a white background. 我希望,当立方体旋转并且光标移动(或没有)时,包含光标的前向侧将具有白色背景。 But in practice that doesn't happen properly. 但在实践中,这种情况并不恰当。 If I scroll the cursor over the animation it picks out the correct panel to highlight but then it often fails to update when it should. 如果我将光标滚动到动画上,它会选出正确的面板以突出显示但是它通常无法更新。 Most noticeably, if I stop moving the mouse it doesn't seem to detect any change in what element the cursor might be hovering over. 最值得注意的是,如果我停止移动鼠标,它似乎没有检测到光标可能悬停在哪个元素上的任何变化。

Is this a known shortcoming? 这是一个众所周知的缺点吗? Does anyone have a solution? 有没有人有办法解决吗?

It appears there's a difference in Chrome's Webkit engine vs Firefox's Gecko engine. 看来Chrome的Webkit引擎与Firefox的Gecko引擎存在差异。 Firefox continually runs to check a hover status, while Chrome does not. Firefox不断运行以检查悬停状态,而Chrome则不会。

I tested it in Chrome and Safari (both run Webkit) and they have similar results. 我在Chrome和Safari(都运行Webkit)中进行了测试,结果相似。 They do not update the hover state if you keep the mouse still. 如果保持鼠标静止,它们不会更新悬停状态。 Firefox, on the other hand, continually checks the hover area when the mouse remains in the same place. 另一方面,当鼠标停留在同一个地方时,Firefox会不断检查悬停区域。

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

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