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

subgrid

Skill này làm gì

Skill này cho thấy cách dùng CSS subgrid để các phần tử lồng nhau thẳng hàng với hàng hoặc cột của lưới cha. Skill dành cho người xây web có bố cục card trông không đều.

Khi nào nên dùng

  • ✓Khi một lưới card có tiêu đề, văn bản hoặc nút không thẳng hàng giữa các card.
  • ✓Khi có người yêu cầu căn chỉnh các phần tử lưới lồng nhau mà không dùng JavaScript.
  • ✓Khi rà soát bố cục lưới CSS mà các phần tử con cần đi theo các track của lưới cha.

Liên kết skill

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

“Các sản phẩm của tôi trông không đều vì tiêu đề và nút không thẳng hàng. Bạn có thể sửa bố cục chỉ bằng CSS không?”

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

Cách hoạt động

Agent làm cho các phần tử con dùng hàng hoặc cột của lưới cha. Sau đó trình duyệt tự căn thẳng các phần tương ứng của từng card.

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 subgrid to align nested grid items to parent tracks

Card grids are one of the most common UI patterns, but aligning content across cards — matching title heights, content areas, and footers — has historically required JavaScript height measurement or CSS hacks. Subgrid solves this at the layout engine level: nested items participate directly in the parent grid's tracks, so alignment is automatic, performant, and CSS-only.

Quick Reference

  • subgrid lets a nested grid inherit its parent grid tracks instead of creating new ones
  • Solves misaligned card titles, content, and footers across rows of cards
  • No JavaScript height matching needed — the browser handles track alignment
  • Universal support: Safari 16+, Chrome/Edge 117+, Firefox 71+

Check

Look for card grid layouts in this CSS where card content areas (titles, body text, footers) might not align across cards of different content lengths. These are candidates for subgrid.

Fix

Convert this card grid to use subgrid. Show how to set grid-template-rows on the parent grid, then apply grid-row: span N and grid-template-rows: subgrid on each card to inherit the parent tracks.

Explain

Explain how CSS subgrid works, how it differs from a nested grid, what problem it solves with card alignment, and when to use subgrid on columns versus rows.

Code Review

Review card grid and nested grid layouts in this stylesheet. Flag any layout that uses JavaScript height matching, fixed heights, or display: contents workarounds to achieve cross-card alignment — and show the subgrid equivalent.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/css/subgrid

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

Subgrid có chạy trên mọi trình duyệt không?

Skill ghi nhận hỗ trợ trên Safari 16 trở lên, Chrome và Edge 117 trở lên, và Firefox 71 trở lên.

Subgrid có tốt hơn việc dùng JavaScript để cân chiều cao không?

Theo skill này thì có. Trình duyệt tự xử lý việc căn chỉnh, nên không cần script để đo và cân chiều cao.

Nên dùng subgrid cho cột hay cho hàng?

Tùy vào hướng cần căn thẳng. Skill giải thích cả hai trường hợp để agent chọn đúng.

Chi tiết

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

Use when reviewing card grid layouts with misaligned content areas, or any nested grid where child items need to align with sibling cards' corresponding sections without JavaScript intervention.

repo: thedaviddias/Front-End-Checklist

Độ phổ biến

Sao GitHub
75k
Vị trí xếp hạng
#3040
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ự