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

css-grid

Skill này làm gì

Skill này giải thích cách dùng CSS Grid cho bố cục cần cả hàng và cột. Skill dành cho lập trình viên front end muốn bố cục đáp ứng với ít code hơn.

Khi nào nên dùng

  • ✓Khi bố cục cần hàng và cột thẳng hàng với nhau.
  • ✓Khi các cách dùng float hoặc flex vá víu bị hỏng trên màn hình khác nhau.
  • ✓Khi bạn muốn lưới thẻ đáp ứng mà không cần nhiều media query.

Liên kết skill

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/css-grid/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-grid/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

“Hãy xây lại danh sách sản phẩm của tôi thành một lưới đáp ứng, tự thích nghi theo chiều rộng màn hình.”

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

Cách hoạt động

Agent đặt các track và vùng có tên cho lưới, dùng minmax và auto-fill để tạo cột đáp ứng, và dùng subgrid khi các phần tử lồng nhau cần thẳng hàng với lưới cha.

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 Grid for two-dimensional layouts

CSS Grid solves layout problems that previously required JavaScript or complex CSS hacks — aligning items across both axes simultaneously, creating named layout areas, and building responsive grids that adapt to content. Using Flexbox for two-dimensional layouts results in workarounds like fixed widths that break responsiveness.

Quick Reference

  • Use Grid for two-dimensional layouts (rows AND columns); use Flexbox for one-dimensional
  • grid-template-areas provides a visual representation of the layout in your CSS
  • minmax() and auto-fill/auto-fit create responsive grids without media queries
  • Subgrid allows nested elements to align to the parent grid's tracks

Check

Look for float-based or Flexbox layouts in this CSS that are trying to control both rows and columns — they may be better implemented with CSS Grid.

Fix

Convert this two-dimensional layout to use CSS Grid with appropriate grid-template-columns, grid-template-rows, and grid-template-areas.

Explain

Explain CSS Grid fundamentals: tracks, cells, areas, fr units, minmax, and auto-fill vs auto-fit.

Code Review

Review stylesheets, component styles, and responsive states related to Use CSS Grid for two-dimensional layouts. 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-grid

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

Khi nào nên dùng Grid thay vì Flexbox?

Skill nói Grid dùng cho bố cục hai chiều có cả hàng và cột, còn Flexbox dùng cho một chiều.

subgrid là gì?

Skill nói nó cho phép các phần tử lồng nhau căn theo các track của lưới cha.

Lưới có thể đáp ứng mà không cần media query không?

Có. Skill nói minmax kết hợp với auto-fill hoặc auto-fit có thể tạo lưới đáp ứng.

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 Grid for two-dimensional layouts. 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
#2799
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ự