CSS Containment 是什么以及如何使用它?
Written by Harry Roberts on CSS Wizardry.
由 Harry Roberts 在 CSS Wizardry 上撰写。
Table of Contents
目录
Independent writing is brought to you via my wonderful Supporters.
独立写作通过我精彩的 Supporters 呈现给你。
- Why Containment Exists
- 为什么存在 Containment
- Meet the
containProperty - 认识
contain属性 - Layout Containment
- Layout Containment
- Paint Containment
- 绘制包含
- Size Containment
- 尺寸包含
- Style Containment
- 样式包含
- Special Values:
contentandstrict - 特殊值:
content和strict - Containment in the Real World
- 真实世界中的包含
content-visibilityandcontain-intrinsic-sizecontent-visibility和contain-intrinsic-size- Caveats, Gotchas, and Things to Watch for
- 注意事项、陷阱和需要留意的事项
- When to Use Containment
- 何时使用包含
- Closing Thoughts
- 结束语
Continuing my work on web performance for design systems, I want to look at a woefully underused CSS feature called containment. I fear it’s underused because there isn’t much written about it, so this piece aims to be the post I wish I’d been able to read a few years ago. Hopefully it demystifies things a little for you, too.
继续我关于 设计系统的 Web 性能 的工作,我想来看看一个严重未充分利用的 CSS 特性,名为 containment。我担心它未被充分利用是因为关于它的内容不多,所以这篇文章旨在成为几年前我希望能读到的那篇文章。希望它也能为你稍微揭开一些神秘面纱。
Modern UIs are busy places. A single page might contain a fixed header, an infinite scroll feed, a sticky cart summary, and a few different third-party widgets stuck around the edges. Every time something changes, the browser needs to decide how much of that page it has to re-think: styles, layout, painting, compositing, and so on.
现代 UI 是繁忙的地方。一个单页可能包含固定的页眉、无限滚动的内容流、粘性购物车摘要,以...