Flex free-space simulator

Calculate item sizes from container width, basis, grow and shrink. Inspect free-space and shrink weighting in a single-line model with explicit zero minimums.

The example value has been entered. Check it immediately or change the value.

Input is processed in the browser. Refreshing returns a sample value.

Result

Instructions and example

After gaps, distribute free space by grow and deficits by shrink×basis. Freeze negative sizes at 0 and redistribute.

500px minus gap 20px and bases totaling 200px leaves 280px. Grow ratio 1:2 yields about 193.333px and 286.667px.

Up to 30 items. Assumes min-width:0, unlimited max-width and no border, padding or margin. Wrapping, intrinsic sizing and actual DOM layout are excluded.

Frequently asked questions

Do different Flex bases shrink equally?

No. Shrink weighting is the product of shrink and basis.

Can free space remain when Flex grow sums below 1?

Yes. When the sum is below 1, the rule distributes only part of the free space.

Calculation criteria and reference materials

Verification of calculation criteria: · Calculation·verification principles · Report errors