示例工程 50-performance
50-performance/demo-02-containment/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>内容隔离</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<h1>内容隔离</h1>
<p>屏幕外的列表项延迟渲染。</p>
<div class="list">
<article class="item"><h2>项目 1</h2><p>content-visibility: auto</p></article>
<article class="item"><h2>项目 2</h2><p>contain-intrinsic-size 预留高度</p></article>
<article class="item"><h2>项目 3</h2><p>屏幕外跳过渲染</p></article>
<article class="item"><h2>项目 4</h2><p>滚动条不跳动</p></article>
<article class="item"><h2>项目 5</h2><p>按需绘制</p></article>
<article class="item"><h2>项目 6</h2><p>复杂卡片可加 contain</p></article>
</div>
<div class="card">
<span class="code">contain: layout paint</span>
<p>这张卡片的重排不会影响外部。</p>
</div>
</body>
</html>