是否有针对 Opera 可见性转换错误的 CSS 解决方法?

发布于 2024-12-10 16:19:27 字数 308 浏览 1 评论 0原文

这是一个开始的小提琴: http://jsfiddle.net/kizu/A7QX9/

问题:在 Opera 中,当您为 visibility 属性(通常与 opacity 一起)设置过渡动画时,它的动画效果不正确:visibility 始终更改为过渡结束,因此当块出现时,它不会顺利出现。

那么,问题是:是否有任何仅 CSS 的解决方法来解决这个 Opera 的错误?

Here is a fiddle for start: http://jsfiddle.net/kizu/A7QX9/

The problem: in Opera when you animate the transition for visibility property (usually along with the opacity) it's not animated properly: the visibility is changed always at the end of transition, so when the block is appearing it's not appearing smoothly.

So, the question: is there any CSS-only workaround for this Opera's bug?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请别遗忘我 2024-12-17 16:19:27

在我提出问题并思考一段时间后,我自己找到了答案。

并想出了一个解决方案。

因此,逐步进行:

  1. 让我们看一下需要显示开始时隐藏的块的情况。
  2. 当您使用过渡切换不透明度可见性时,当过渡处于运行状态时,块将保持visibility:hidden状态。因此,您不需要在此处使用过渡来实现可见性。
  3. 但是,当您再次隐藏该块时,您需要在转换结束时切换可见性,因此显然需要在此处进行转换。
  4. 因此,在隐藏块的选择器中,您必须具有不透明度的过渡,而在显示块的选择器中,则不需要过渡。

这是我用这个解决方案制作的小提琴: http://jsfiddle.net/kizu/A7QX9/ 1/

After I formulated the question and thought for a while, I've found the answer myself.

And came up with a solution.

So, going step-by-step:

  1. Let's look at the case when you need to show the block which is hidden at the start.
  2. When you toggle the opacity and visibility with a transition, the block stays with visibility: hidden while the transition is in the run. So, you don't need to use transition for visibility here.
  3. But when you hide the block again, you need to toggle the visibility at the end of the transition, so you need the transition here apparently.
  4. So, at the selector where the block is hidden you must have the transition for the opacity and in the selector where it's shown, you don't need the transition.

Here is a fiddle I've made with this solution: http://jsfiddle.net/kizu/A7QX9/1/

听不够的曲调 2024-12-17 16:19:27

Opera 中当前过渡的实现基于旧版规范,该版本规定转换可见性“1 是“可见”,所有其他值都是“隐藏”。”

因此,如果您尝试从“隐藏”转换为“可见”,那么您将看不到该元素,直到表示转换的底层 0-1 范围达到值 1。
同时,如果您从“可见”过渡到“隐藏”,则一旦开始过渡,元素就会消失,因为值将小于 1。

您期望的行为在规范的“草案”版本中指定,其中表示“0 是“隐藏的”,所有其他值都是“可见的”。”

不过好消息是 - Opera 12 将修复此错误。预计很快就会在 Desktop Team 博客 上看到带有修复程序的测试版本。

Current implementation of transitions in Opera is based on an older version of the spec saying that for transitioning visibility "1 is "visible" and all other values are "hidden"."

So if you try transitioning from "hidden" to "visible" then you won't see the element until underlying 0-1 range representing transition reaches value 1.
At the same time, if you are transitioning from "visible" to "hidden" then element will disappear as soon as transition has started as value will be <1.

The behavior that you expect is specified in the "draft" version of the spec which says that "0 is "hidden" and all other values are "visible".".

Good news though - Opera 12 will include fix for this bug. Expect to see testing build with a fix on Desktop Team blog soon.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文