CSS Grid Auto Placement Demo - Online How Items Flow
See how grid-auto-flow: row vs column changes item placement. Add and remove items to understand the algorithm. Visual.
UD5 Toolkit
Understand CSS Grid auto-fill vs auto-fit with real-time visual comparison
auto-fill and auto-fit tell the browser to create as many grid tracks as possible within the available space. The key difference: auto-fill preserves empty tracks (leaving visible gaps where items could go), while auto-fit collapses empty tracks and lets existing items stretch to fill the available space. Think of auto-fill as "reserving seats" and auto-fit as "only setting up chairs for people who showed up."
minmax(), the behavior difference is barely noticeable. The minmax(min, 1fr) pattern is essential because the 1fr maximum allows auto-fit items to grow and fill extra space when empty tracks collapse. If you use a fixed value like minmax(150px, 150px), both auto-fill and auto-fit behave identically — columns stay at 150px and the extra space just sits unused. The 1fr is what makes the visual difference dramatic.
repeat(auto-fit, 200px) is valid CSS — it creates as many 200px columns as fit, and collapses empty ones. However, without 1fr, there's no stretching behavior. The items stay at exactly 200px. The minmax() function unlocks responsive flexibility: columns can be at least the minimum but expand when space allows. This is what makes auto-fit layouts feel truly fluid and responsive.
minmax()'s minimum value, both auto-fill and auto-fit behave the same: they create a single column, and the item width is clamped to the container width (potentially overflowing if content is larger). This is why choosing a sensible minimum (like 200px–280px) is important for mobile-responsive designs. Test your layout at narrow widths to ensure items don't become unusably small.
minmax(140px, 1fr): available width ≈ 620px − (n−1)×12px (where n is the number of columns). The browser then determines how many 140px columns fit. Gaps consume space, so larger gaps reduce the maximum number of columns. This is why adjusting gap can sometimes cause items to wrap or unwrap.
auto-fill and auto-fit are part of the CSS Grid Level 1 specification and have excellent browser support — all modern browsers including Chrome 57+, Firefox 52+, Safari 10.1+, and Edge 16+ support them fully. They're safe for production use. Internet Explorer 11 had partial grid support but did not support auto-fill/auto-fit, so if IE11 support is required, you'll need a fallback like @supports queries.
auto-fill/auto-fit with fixed track sizes in grid-template-columns. For example: grid-template-columns: 200px repeat(auto-fill, minmax(150px, 1fr)) 80px; — this creates a 200px sidebar, flexible center columns, and an 80px end column. The auto-fill/auto-fit only applies to the repeated section, while fixed tracks remain constant. This is powerful for complex responsive layouts.
minmax() maximum must be a flexible unit like 1fr — if it's a fixed pixel value, items won't stretch. (2) Ensure there are fewer items than the maximum possible columns — if all tracks are filled, auto-fill and auto-fit look identical. (3) Check that grid items don't have explicit max-width or justify-self constraints that override the grid's sizing. Use your browser's DevTools grid inspector to see exactly how tracks are being sized.
See how grid-auto-flow: row vs column changes item placement. Add and remove items to understand the algorithm. Visual.
Visually name grid areas in a table and generate grid‑template‑areas CSS. Perfect for complex layouts. Drag‑free.
Beautify and format your CSS stylesheets instantly. Organize, minify, or prettify CSS code for better readability. Processed securely on client-side.
Paste your full CSS and HTML; automatically identify and extract the styles needed for the visible part. Reduce render‑blocking resources.
Compare width/height with block‑size/inline‑size in different writing modes. Understand intrinsic sizing. Copy best practices.
Draw walls on a grid and watch A*, Dijkstra, or BFS find the shortest path. Interactive animation. Learn graph traversal.
Use named grid lines instead of column numbers. See how they simplify placement. Visual, interactive learning.
Multiple digital counters for tracking stitches, rows, and pattern repeats. Increment, reset. Works on mobile.
New CSS text‑spacing property for fine control over punctuation spacing. See the effect live. For advanced typography.
Start from a base color and use `oklch(from color l c h)` to create lighter or darker variants. Copy the code.
Drag a slider to compare your original image with a compressed version (e.g., WebP). See the quality difference and file size savings.
Detect browser support for font‑tech() and font‑format() values in @font‑face src. Check COLRv1, variable, etc.
Toggle scroll‑behavior: smooth and click anchor links to see the scrolling animation. Implement modern UX.
Plot different Big‑O complexities on a chart. See how O(log n) stays flat while O(2^n) explodes. Educational reference.
Stack multiple background images and blend them with colors. Create unique textures. Copy the CSS code instantly.
Enter a URL and see a visual map of the tab order. Detect broken tabindex values. Improve keyboard navigation.
See the difference between :focus and :focus‑visible on interactive elements. Learn which to use for better UX.
Paste your CSS and sort the properties of each rule alphabetically or by concentric groups. Keep your stylesheets consistent without a build step.
Enter text and see each character's 8‑bit binary laid out in a black‑and‑white grid. Beautiful data art. Local.
Apply the drop‑shadow() filter and compare it with box‑shadow. See how it follows the contour of transparent images. Copy code.
Paste HTML and see the order in which elements would receive focus via Tab key. Highlight issues. Local accessibility testing.
Create vertically oriented text layouts with `writing‑mode`. See the effect and copy the complete CSS. For vertical languages.
Apply content‑visibility: auto to off‑screen sections and see the rendering cost drop. Demos for infinite scroll optimization.
Toggle between light and dark mode for a demo page. See how to use the media query. Copy the pattern.
Compare break‑all, keep‑all, and overflow‑wrap: anywhere/break‑word. Paste long words and see how they wrap.
Watch classic sorting algorithms step through a randomized bar chart. Adjust speed and array size. Great for learning algorithm efficiency.
Test overscroll‑behavior: contain to prevent background scroll or pull‑to‑refresh. See the effect in a live demo.
Create seamless CSS background patterns like stripes, polka dots, checkerboard. Adjust size and colors. Copy the tiny CSS.
Animated SVG steps showing how to fold a fitted sheet perfectly. Clean visual reference.
Upload a small image and see it tiled as a canvas pattern. Export the pattern or copy the JavaScript.