css-containment
できること
このスキルは、containプロパティとcontent-visibilityを使って、特定のコンポーネントが自己完結していることをブラウザに伝える方法を示します。コンポーネントが多いページが遅く感じられる開発者向けです。
使う場面
- ✓独立したコンポーネントが多いページの更新が遅く感じられるとき。
- ✓長いリストが、画面の外にあるコンテンツを描画しているとき。
- ✓ウィジェットがはみ出さず、ページの他の部分に影響する必要がないとき。
スキルのリンク
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/css-containment/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“私の長い商品リストはスクロールすると重く感じます。画面の外の項目が描画の負担を減らすように、containmentを追加してください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
エージェントは、自己完結したコンポーネントにcontainの値を追加し、繰り返される画面外のリストの項目にはcontent-visibility: autoを追加します。その前に、はみ出さず隣接する要素に影響しないことを確認します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Use CSS containment to limit repaint scope
By default, a CSS change anywhere on the page can potentially affect any other element's layout. CSS containment declares that certain elements are isolated — changes inside them don't affect the outside world. This lets browsers skip large portions of the rendering pipeline for unchanged content, which is especially valuable for pages with many independent components.
Quick Reference
- contain: layout style paint tells the browser a component is visually self-contained
- content-visibility: auto skips rendering off-screen content entirely
- Containment limits how far layout recalculations need to propagate
- Use contain: strict for widgets with no overflow that shouldn't affect the page
Check
Identify components in this CSS that are visually self-contained (no overflow, no interaction with elements outside) and could benefit from CSS containment.
Fix
Add appropriate contain values to self-contained components. Add content-visibility: auto to repeated off-screen list items.
Explain
Explain CSS containment values, how they limit rendering scope, and when content-visibility: auto provides the biggest benefit.
Code Review
Review stylesheets, component styles, and responsive states related to Use CSS containment to limit repaint scope. Flag exact selectors, declarations, or breakpoints that violate the rule in the rendered UI.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/css-containment
よくある質問
containは何をしますか?
コンポーネントが見た目の上で自己完結していることをブラウザに伝え、レイアウトの処理をその中に留められると、このスキルは説明しています。
content-visibility: autoは何をしますか?
画面の外にあるコンテンツの描画を省くと、このスキルは説明しています。
contain: strictはいつ使いますか?
はみ出さず、ページの他の部分に影響させるべきでないウィジェットに使います。
詳細
作者による元の説明
Use when reviewing stylesheets, component styles, and responsive behavior related to Use CSS containment to limit repaint scope. Check the rendered layout across breakpoints and interaction states before proposing a fix.
人気
- GitHubのスター
- 75k
- ランキング
- #2795
- ライセンス
- MIT
- 更新日
- 2026/10/31
コメント
- …
このリポジトリの他のスキル
frontendchecklist
75kコマンドラインツールを使って、フロントエンドのコードとライブページを、アクセシビリティ、速度、SEO、セキュリティに関する380以上のルールと照らし合わせて確認します。
frontend-checklist-global
75kフロントエンドのプロジェクトを、386のFront-End Checklistのルールすべてと照らし合わせて監査し、見つかった問題ごとに具体的な修正方法を示します。
404-page
75k見つからないページの画面に役立つリンクがあり、本物の404ステータスを返すかを確認し、迷った訪問者が目的のページを見つけられるようにします。
about-page
75kサイトの運営者が誰かを説明する、分かりやすいAboutページがあるかを確認し、訪問者と検索エンジンからの信頼を高めます。
似ているスキル
angular-developer
280kエージェントがAngularのコードを作成し、プロジェクト構成についてアドバイスできるようにします。新しいプロジェクトの開始、コード部品の作成、パフォーマンスやアクセシビリティの改善に役立ちます。
frontend-a11y
280kエージェントが Web インターフェースを誰にとっても使いやすくするよう支援します。スクリーンリーダーやキーボード操作に対応し、サイトやアプリが適切に動作するようにします。
frontend-patterns
280kエージェントがフロントエンド開発の最新パターンを適用できるようにします。React と Next.js において、パフォーマンスの最適化、状態管理、ベストプラクティスの遵守を行います。