ToolzYard

Free online developer tools

Free • No Signup

CSS Generators

Free online CSS generators that run in your browser. Build gradients, box shadows, rounded corners, flexbox and grid layouts, pick colors, and beautify or minify code. Live preview and copy-paste CSS, no sign-up.

Flexbox or Grid? One dimension versus two

The choice is not about preference — the two tools solve different shapes of problem, and the fastest way to pick is to ask whether you are laying out along one axis or two.

Flexbox is one-dimensional. It arranges items along a single axis — a row or a column — and is content-driven: items size themselves from their content while you distribute the leftover space. Reach for it for a nav bar, a toolbar, a row of buttons, or centering one thing inside another.

Grid is two-dimensional. It controls rows and columns at the same time and is container-driven: you define the tracks and place items into them, so things line up across both axes. Reach for it for page and section layouts, card galleries, or any design where alignment has to hold vertically and horizontally at once.

They are not rivals — they compose. A grid item can be a flex container, and a flex item can be a grid. A practical rule: use Grid to define the overall structure, and Flexbox to arrange the items sitting inside one cell or one row of it.

Shadows, corners, and gradients: the sharp edges

Why animating box-shadow is janky

box-shadow is expensive to paint, and animating it forces the browser to repaint every frame, which drops frames on lower-end devices. The fix is to animate compositor-only properties instead — transform and opacity run on the GPU without triggering a repaint. A common pattern is to render the larger shadow on a pseudo-element and animate its opacity from 0 to 1, so the shadow appears to grow on hover without any per-frame repainting.

The slash in border-radius makes elliptical corners

border-radius accepts an optional / that separates horizontal from vertical radii. border-radius: 50px / 20px gives every corner a 50px horizontal radius and a 20px vertical radius — an ellipse, not a circle. The full eight-value form, border-radius: a b c d / e f g h, sets all four horizontal radii before the slash and all four vertical radii after it, which is how the organic "blob" and squircle shapes are built.

Why a gradient goes grey in the middle

A gradient interpolates between its colors through a color space, and the default sRGB interpolation passes through a desaturated, muddy grey when the two endpoints sit far apart on the color wheel — blue to yellow being the classic case. That washed-out midpoint is the "grey dead-zone." CSS Color 4 lets you choose the interpolation space to avoid it: linear-gradient(in oklch, blue, yellow) interpolates through a perceptual space and keeps the mix vivid, and in hsl travels around the hue wheel instead of cutting through grey.

Frequently Asked Questions

When should I use Flexbox instead of CSS Grid?

Use Flexbox for one-dimensional layouts — a single row or column such as a nav bar or a group of buttons — where items size from their content. Use Grid when you need to control rows and columns together, like a page layout or a card gallery that must align on both axes.

Can I use Flexbox and Grid in the same layout?

Yes. They nest and compose freely: a Grid item can be a flex container and a flex item can be a grid. A common approach is Grid for the overall page structure and Flexbox for arranging the contents of individual cells.

Why is my box-shadow animation stuttering?

Animating box-shadow forces a repaint on every frame, which is costly. Animate transform and opacity instead — they are handled by the compositor on the GPU. A common trick is to put the shadow on a pseudo-element and fade its opacity.

What does the slash in border-radius do?

It separates horizontal and vertical radii to create elliptical corners. border-radius: 50px / 20px makes each corner 50px wide and 20px tall rather than a quarter-circle. The eight-value form lists all horizontal radii before the slash and all vertical radii after it.

Why does my gradient look grey or muddy in the middle?

By default a gradient interpolates in the sRGB color space, which passes through a desaturated grey when the two colors are far apart on the color wheel. Interpolate in a perceptual or hue-based space instead, for example linear-gradient(in oklch, blue, yellow), to keep the transition vivid.

Browse other tool categories