concept
Responsive component — CSS reference
A responsive component adapts to its available space rather than assuming one device category. Auto-fitting grid tracks can accommodate two cards in a wide container and stack them in a narrow one. This test changes the component width without changing the viewport.
Formal Syntax & Structure
css syntaxcss
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));Working Example
Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>responsive-component</title><style>body{margin:8px;font:16px/24px sans-serif;color:black;background:white}#a{box-sizing:border-box}#a{display:grid;width:240px;grid-template-columns:repeat(auto-fit,minmax(100px,1fr));gap:8px}</style><body><div id="a"><div id="b">First</div><div id="d">Second</div></div></body></html>