【发布时间】:2019-12-05 13:33:18
【问题描述】:
将显示设置为阻止后是否运行动画?
我正在设置元素的动画样式,然后将显示从无设置为阻塞。它正在为我播放动画,但我读过显示不会触发动画。谁是正确的?
部分代码:
// method 1 - enable a media query
var animation = "fadein 1s ease-out";
element.style.setProperty("animation", null, "important");
element.style.setProperty("animation", animation, "important");
enableQuery(rule); // manually enable a media query
// method 2 - set display none to block
element.style.display = "block";
var animation = "fadein 1s ease-out";
element.style.setProperty("animation", null, "important");
element.style.setProperty("animation", animation, "important");
CSS
@keyframes fadein {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
如果您在媒体查询之外没有显示,然后您启用了将显示设置为阻止的媒体查询,那么这会导致动画播放吗? requestAnimationFrame 是否适合其中任何一种?
【问题讨论】:
-
也许显示您的代码会让您怀疑您阅读的内容?此外,参考您所阅读的内容也会很有用。
-
Display block 和 none 之间没有动画。
-
启用媒体查询会是播放动画的内容吗?另外,我也在 none 和 block 之间切换,然后我使用上面的代码来启动它。
-
显示和不透明度是两个不同的东西
标签: javascript html css