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

flexbox-patterns

Skill này làm gì

Skill này rà soát mã CSS flexbox tìm các lỗi phổ biến làm hỏng bố cục. Skill dành cho lập trình viên xây bố cục trang bằng flex.

Khi nào nên dùng

  • ✓Khi chữ bị tràn hoặc bị cắt bên trong một hàng flex.
  • ✓Khi khoảng cách giữa các phần tử flex không đều hoặc khó kiểm soát.
  • ✓Khi các phần tử co hoặc giãn theo cách bạn không định.

Liên kết skill

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

“Bạn có thể kiểm tra CSS flexbox của tôi xem có lỗi nào làm hỏng bố cục không?”

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

Cách hoạt động

Agent tìm các cài đặt flex gây co lại hoặc tràn, và các margin được dùng ở chỗ gap sẽ phù hợp hơn. Agent gợi ý giá trị đã sửa và sửa min-width nếu 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.

Apply Flexbox best practices

Flexbox is one of the most used CSS features, but its unintuitive default values (flex-shrink:1, min-width:auto) cause layout bugs that are hard to diagnose. Understanding the flex shorthand and the min-width:0 fix prevents the most common Flexbox breakage scenarios.

Quick Reference

  • Flexbox is for one-dimensional layouts (a row OR a column)
  • Use flex: 1 1 0 (shorthand: flex:1) for equal-width items that fill space
  • Add min-width: 0 to flex children when text overflow truncation doesn't work
  • Use gap instead of margin for spacing between flex items

Check

Review this CSS for common Flexbox mistakes: missing min-width:0 on text-containing flex children, using margin instead of gap for spacing, and improper flex shorthand usage.

Fix

Fix the Flexbox layout issues: add min-width:0 where needed, replace inter-item margins with gap, and correct flex shorthand values.

Explain

Explain how flex-grow, flex-shrink, and flex-basis work, what the flex shorthand means, and why min-width:0 fixes text overflow in flex layouts.

Code Review

Review stylesheets, component styles, and responsive states related to Apply Flexbox best practices. 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/flexbox-patterns

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

Vì sao chữ bị tràn trong bố cục flex?

Các phần tử con của flex có chiều rộng tối thiểu mặc định có thể ngăn chữ co lại, và skill gợi ý đặt min-width bằng 0 để sửa.

Nên dùng gap hay margin?

Skill khuyên dùng gap cho khoảng cách giữa các phần tử flex.

flex 1 nghĩa là gì?

Skill giải thích đó là cách viết tắt cho các phần tử cùng chia đều phần không gian còn trống.

Chi tiết

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

Use when reviewing stylesheets, component styles, and responsive behavior related to Apply Flexbox best practices. 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
#2848
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ự