zoukankan      html  css  js  c++  java
  • [CSS 3] content-visibility: auto Improve rendering performance

    When page get loaded, browser need to calculate how to render the page even before first pixel get rendered.

    Also means that for the content which is outside or viewport, broswer also need to calculate it.

    With Chrome 85, if you set parent container to :

    .container {
     content-visibility: auto
    }

    makes the initial user load much faster.

    More details

    Specifying the natural size of an element with contain-intrinsic-size #

    In order to realize the potential benefits of content-visibility, the browser needs to apply size containment to ensure that the rendering results of contents do not affect the size of the element in any way. This means that the element will lay out as if it was empty. If the element does not have a height specified in a regular block layout, then it will be of 0 height.

    This might not be ideal, since the size of the scrollbar will shift, being reliant on each story having a non-zero height.

    Thankfully, CSS provides another property, contain-intrinsic-size, which effectively specifies the natural size of the element if the element is affected by size containment. In our example, we are setting it to 1000px as an estimate for the height and width of the sections.

    This means it will lay out as if it had a single child of "intrinsic-size" dimensions, ensuring that your unsized divs still occupy space. contain-intrinsic-size acts as a placeholder size in lieu of rendered content.

    .container {
      content-visibility: auto;
      contain-intrinsic-size: 1000px; /* Explained in the next section. */
    }
  • 相关阅读:
    Codeforces Round#410 Div.2
    AtCoder Beginner Contest-060
    如何将gedit变成c++编译器
    洛谷 P2486 [SDOI2011]染色
    让lu哥头痛了许久的代码(洛谷:树的统计)
    字符串模拟入门
    luogu P1553 数字反转(升级版)
    那些令人难忘的——坑
    luogu P1341 无序字母对
    最短路相关题目
  • 原文地址:https://www.cnblogs.com/Answer1215/p/13634507.html
Copyright © 2011-2022 走看看