【发布时间】:2014-06-28 11:07:41
【问题描述】:
考虑到下面这个简单的例子,想知道为什么在使用的时候没有触发CSS3的过渡效果 DOMContentLoaded?使用 window.onload 或 document.onreadystatechange = "complete" 即可!
我知道 DOMContentLoaded 不等待 [style] 但在这种情况下我不引用外部 样式表!
如果支持,大多数 DomReady-Engines 将退回到 DOMContentLoaded! 也许有人对我有一些关于这个问题的想法或信息! 提前谢谢!
示例:
<!DOCTYPE html>
<html>
<head>
<script>
window.document.addEventListener('DOMContentLoaded', function() {
var elem = window.document.getElementById('box1');
elem.style.height = '400px';
elem.style.transition = "height 1s ease-in";
}, false);
</script>
</head>
<body>
<div id="box1" style="display:block; background-color:green; position:absolute; width:400px; height:100px;" >Doesn't animate in IE, Opera, Chrome etc.. but often in FIREFOX</div>
</body>
</html>
【问题讨论】:
-
你最终解决了这个问题吗?
-
介意我的回答怎么解决不了?
-
它与异步执行(setTimeout)一起工作,但这不是我的目标
-
我在这里回答了这个问题:stackoverflow.com/a/46991428/1026
标签: css-transitions domcontentloaded