Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)75k · #2795

css-containment

Skill này làm gì

Skill này cho thấy cách báo cho trình duyệt biết rằng một số component tự chứa, bằng thuộc tính contain và content-visibility. Skill dành cho lập trình viên có trang nhiều component cảm thấy chậm.

Khi nào nên dùng

  • ✓Khi một trang có nhiều component độc lập cảm thấy chậm khi cập nhật.
  • ✓Khi danh sách dài hiển thị nội dung nằm ngoài màn hình.
  • ✓Khi một widget không có overflow và không cần ảnh hưởng tới phần còn lại của trang.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/css-containment/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/css-containment/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Danh sách sản phẩm dài của tôi chậm khi cuộn. Hãy thêm containment để các mục ngoài màn hình được render ít hơn.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Agent thêm các giá trị contain cho component tự chứa và content-visibility auto cho các mục danh sách lặp lại nằm ngoài màn hình, sau khi kiểm tra chúng không tràn hoặc ảnh hưởng đến các phần tử lân cận.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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

Câu hỏi thường gặp

contain làm gì?

Skill nói nó báo cho trình duyệt biết component tự chứa về mặt hiển thị, để công việc bố cục nằm gọn bên trong.

content-visibility auto làm gì?

Skill nói nó bỏ qua việc render nội dung nằm ngoài màn hình.

Khi nào dùng contain strict?

Cho các widget không có overflow và không nên ảnh hưởng tới phần còn lại của trang.

Chi tiết

Mô tả gốc của tác giả

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.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#2795
Giấy phép
MIT
Cập nhật
31/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự