我想知道为什么我的CSS过渡效果在Firefox中看起来很棒,而在IE和Chrome中非常"跳跃"。我现在一整天都在研究这个,我不明白为什么会发生这种情况。我试过正面可见,但也不管用。我完全被这个卡住了…
我有这个:
<div class="stickyWrap">
<div id="header">content</div>
<div id="nav">content</div>
</div>
CSS: #header{
-webkit-transition: all 0.3s linear 0s;
-moz-transition: all 0.3s linear 0s;
-o-transition: all 0.3s linear 0s;
transition: all 0.3s linear 0s;
-webkit-backface-visibility: hidden; /* Chrome, Safari, Opera */
backface-visibility: hidden;
padding: 20px 0;
}
.stickyWrap.sticky {
position: fixed;
top: 0;
width: 100%;
z-index: 99;
}
.stickyWrap.sticky #header {
padding: 5px 0;
-webkit-transition: all 0.2s ease-in-out 0s;
-moz-transition: all 0.2s ease-in-out 0s;
-o-transition: all 0.2s ease-in-out 0s;
transition: all 0.2s ease-in-out 0s;
-webkit-backface-visibility: hidden; /* Chrome, Safari, Opera */
backface-visibility: hidden;
}
最好的解释方式是在FF, Chrome和/或IE中打开这个测试站点。有人能看出我哪里做错了吗?是关于stickyWrapdiv吗?
如果你想模拟原生应用动画的流畅性,你仍然可以欺骗浏览器启用GPU渲染。只需添加这行CSS代码
.myAnimatingClass{
transform: translate3d(0,0,0);
}