本章,我们从一个简单的html页面来谈浏览器的渲染流程
    DOM解析—>CSS解析—>样式计算—>布局树—> 图层树 —> 绘制 —> 合并图层

    浏览器渲染步骤
    1、paserHTML
    2、Recalculate Style
    3、Layout
    4、update Layer Tree
    5、Paint
    6、图层上传至GPU
    7、组合图层生成最终屏幕图像(Composite Layers)

    简单例子:

    1. # css/index.css
    2. body{
    3. font-size: 20px;
    4. background-color: lavender;
    5. }
    6. .nav{
    7. width:200px;
    8. height: 200px;
    9. background-color: red;
    10. position: fixed;
    11. right:10px;
    12. bottom: 10px;;
    13. }
    14. .opacity{
    15. opacity: .5;
    16. width:100px;
    17. height: 100px;
    18. background-color: gray;
    19. position: absolute;
    20. z-index: 100;
    21. }
    22. body{
    23. position: relative;
    24. }
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>渲染流程</title>
        <link rel="stylesheet" href="css/index.css">
    </head>
    <body>
        <p><span>重点介绍</span>渲染流程</p>
        <div>
            <p>green</p>
    
        </div>
        <div class="nav">
            <div class="opacity">red</div>
        </div>
    
    </body>
    </html>
    

    第二章 浏览器渲染 - 图1