zoukankan      html  css  js  c++  java
  • css实现硬件加速

    原文请点击一下链接:
    http://blog.teamtreehouse.com/increase-your-sites-performance-with-hardware-accelerated-css


    1. 何为硬件加速

    就是将浏览器的渲染过程交给GPU处理,而不是使用自带的比较慢的渲染器。这样就可以使得animation与transition更加顺畅。

    2. 如何开启硬件加速

    Chrome, FireFox, Safari, IE9+ 以及最新的 Opera都支持硬件加速,只要使用特定的CSS语句就可以开启硬件加速:

    /**使用3d效果来开启硬件加速**/
    .speed-up {
       -webkit-transform: translate3d(250px,250px,250px)
       rotate3d(250px,250px,250px,-120deg)
       scale3d(0.5, 0.5, 0.5);
    }
    

    如果并不需要用到transform变换,仅仅是开启硬件加速,可以用下面的语句:

    /**原理上还是使用3d效果来开启硬件加速**/
    .speed-up{
       -webkit-transform: translateZ(0);
       -moz-transform: translateZ(0);
       -ms-transform: translateZ(0);
       -o-transform: translateZ(0);
       transform: translateZ(0);
    }
    

    对于safari以及chrome,可能会在使用animation或者transition时出现闪烁的问题,可以使用以下的解决方法:

       -webkit-backface-visibility: hidden;
       -moz-backface-visibility: hidden;
       -ms-backface-visibility: hidden;
       backface-visibility: hidden;
    
       -webkit-perspective: 1000;
       -moz-perspective: 1000;
       -ms-perspective: 1000;
       perspective: 1000;
    
    /**webkit上也可以用以下语句  **/
       -webkit-transform: translate3d(0, 0, 0);
       -moz-transform: translate3d(0, 0, 0);
       -ms-transform: translate3d(0, 0, 0);
       transform: translate3d(0, 0, 0);
    

    3. 注意事项

    硬件加速最好只用在animation或者transform上。不要滥用硬件加速,因为这样会增加性能的消耗,如果滥用反而会使动画变得更加卡,这样就得不偿失了。

  • 相关阅读:
    按钮常用
    MySQL常用Json函数
    MySQL所有函数及操作符
    MySQL常用时间函数
    MySQL常用聚合函数
    Shiro整合Spring
    Shiro集成Web
    Shrio授权验证详解
    Shrio认证详解+自定义Realm
    Shiro入门
  • 原文地址:https://www.cnblogs.com/suhaihong/p/8426225.html
Copyright © 2011-2022 走看看