Make CSS Grid responsive by letting tracks adapt to the space their container actually has, rather than assigning a fixed column count to every device size. For repeated cards, start with repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); use a media query when the layout itself needs to change, such as when a page gains a sidebar.
How do I make a CSS Grid responsive?
CSS Grid is a two-dimensional layout system: it places items across rows and columns, making it useful both for repeated content and for larger page regions. The key is to choose track sizing and placement that can respond to available space and content. See MDN’s overview of CSS Grid.
For a collection of similar items, use an auto-repeat pattern. The browser creates as many columns as fit, and each column can grow to share available room:
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
gap: 1rem;
}
Apply the class to a container of cards:
<section class="card-grid" aria-label="Featured articles">
<article><h2>First article</h2><p>A short summary.</p></article>
<article><h2>Second article</h2><p>Another summary.</p></article>
<article><h2>Third article</h2><p>A third summary.</p></article>
</section>
minmax() sets a lower and upper sizing bound for a track. Here, the lower bound is the smaller of 100% of the container or 15rem, and 1fr lets tracks share the remaining space. The min(100%, 15rem) guard prevents the minimum from forcing a track wider than a narrow container. Choose the minimum and gap based on the content; MDN’s examples use 230px and 200px in particular examples, not as universal card widths or breakpoints. See MDN’s grid layout guide.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Check the container, not only the viewport
Grid responds to the width available to its grid container. A card grid inside a narrow sidebar may need fewer columns than one spanning the viewport. If the grid is constrained by a parent, inspect that parent’s width and sizing when the layout does not behave as expected.
When should I use auto-fit versus auto-fill?
Both keywords create repeated tracks based on the available space. The difference matters when there is room for more tracks than there are items:
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
| Choice | What happens to unused track space | Use it when |
|---|---|---|
auto-fit |
Empty repeated tracks collapse, allowing occupied tracks to expand. | You want a small number of cards to stretch across the available row. |
auto-fill |
Tracks are retained even when no item occupies them, preserving the repeated track pattern. | You want the layout to keep space for potential columns rather than expand the existing items. |
For a common automatically placed product listing, MDN demonstrates auto-fill with minmax(200px, 1fr). That is an example, not a required width. Try both in the actual container: their visible difference depends on the available space, track minimum, and number of items. See MDN’s common grid layouts guide.
How should I size tracks and rows for variable content?
A fixed row height can cause content to overflow when an item needs more room. Let rows grow when their content requires it. For example:
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
.layout {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-auto-rows: minmax(6rem, auto);
gap: 1rem;
}
The columns begin with equal flexible shares; minmax(0, 1fr) gives each track a zero minimum and a flexible maximum. Automatically generated rows have a minimum of 6rem and can grow to fit content because their maximum is auto. Adjust the column count and row minimum to suit the layout, and avoid treating the sample values as universal. MDN documents minmax() for setting track bounds and explains why content can overflow fixed-height rows: Basic concepts of grid layout.
When should I add a media query?
Do not add a breakpoint just because a familiar phone, tablet, or desktop width exists. Intrinsic Grid sizing is often enough when the only change needed is the number or width of columns. A media query is useful when the content calls for a meaningful structural change—for example, moving a sidebar beside the main content at wider widths. MDN recommends relative units for media-query breakpoints rather than targeting particular device widths. Choose the point where the content and layout need to change. See MDN’s responsive design guide and guide to media queries.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Use named areas for major page regions
Named grid areas can make the relationship between page regions easier to understand. Start with a narrow arrangement that follows the content’s reading order, then introduce a wider arrangement if the page needs another column:
.page {
display: grid;
grid-template-areas:
"header"
"main"
"sidebar"
"footer";
gap: 1rem;
}
.page-header { grid-area: header; }
.page-main { grid-area: main; }
.page-sidebar { grid-area: sidebar; }
.page-footer { grid-area: footer; }
@media (min-width: 48rem) {
.page {
grid-template-columns: minmax(0, 2fr) minmax(12rem, 1fr);
grid-template-areas:
"header header"
"main sidebar"
"footer footer";
}
}
The 48rem value is illustrative: set the breakpoint where this content needs the wider composition, not because it corresponds to a named device. The explicit narrow and wide layouts also make the structural change clear. MDN’s common-layout guide includes one-to-three fluid columns and examples adapted with media queries.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
How do I keep Grid placement accessible?
Keep the HTML in a sensible reading order and use Grid primarily to change spatial relationships, not to create a different logical sequence. Visual placement can diverge from source order; that can confuse people using assistive technology or navigating with a keyboard. MDN’s common-layout examples preserve source order to avoid that disconnect. Check the page by reading its content in DOM order and navigating it with a keyboard, not just by looking at the desktop layout.
What should I check when a responsive grid breaks?
- A card is wider than its track: Check whether the item’s intrinsic content or a fixed width is preventing it from shrinking. Consider a zero minimum track such as
minmax(0, 1fr)where appropriate. - A column becomes too narrow: Increase the minimum track size, reduce the gap, or let the design use fewer columns. The minimum is a content decision, not a device breakpoint.
- A grid overflows a narrow container: Check the grid’s parent width and ensure a repeated minimum is not wider than the container. The
min(100%, 15rem)form in the card example handles that case. - Text or content spills out of a row: Avoid a fixed row height when content length varies; use an automatic upper bound such as
minmax(6rem, auto). - Cards stretch unexpectedly when there are only a few: Compare
auto-fillwithauto-fit; the former preserves empty tracks, while the latter lets occupied tracks expand. - Keyboard or screen-reader order feels wrong: Review the HTML source order and avoid using visual repositioning to imply a sequence that the document does not provide.
Or skip the browser setup
After building the layout, you can capture a page to inspect its rendered appearance at a chosen viewport. ScreenshotNeo is a website screenshot API and MCP server. A one-call request can save a screenshot; replace the example URL with your page and use your API key. See the ScreenshotNeo API documentation for parameters and response details.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Before capture, it can accept cookie or consent banners and remove more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.
Frequently Asked Questions
Does CSS Grid replace Flexbox for responsive layouts?
No. Grid is suited to relationships across rows and columns; Flexbox is often more natural for a one-dimensional row or column. A page can use both.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Can a grid have a different number of columns without media queries?
Yes. An auto-repeat track definition such as repeat(auto-fit, minmax(15rem, 1fr)) can fit columns according to available space.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




