随着硬件加速,我发现移动元素发生随机闪烁,特别是在方向变化时. (绝对定位的元素)所以,看到没有值得注意的博客使用这种方法,我想检查是否有一些专业的原因,这是一个坏主意.
解决方法
我将从这篇优秀文章中引用一些内容,但你应该真正阅读它以了解全貌:
http://www.html5rocks.com/en/tutorials/speed/html5/
Currently most browsers only use GPU acceleration when they have a strong indication that an HTML element would benefit from it. The strongest indication is that a 3D transformation was applied to it. Now you might not really want to apply a 3D transformation,but still gain the benefits from GPU acceleration – no problem. Simply apply the identity transformation:
-webkit-transform: translateZ(0);
这背后的原因是,你将cpu必须做的一些工作委托给GPU,但要考虑周到,因为这不一定总是值得的,特别是在像iPad这样的移动设备上,这是你的环境:
Please be warned that this applying this transformation does not guarantee to help your performance. It might simply crank up your GPU,use up more battery but deliver the same performance as before. So be careful with this technique and only use it if you experience a true performance win.