Guide
Calculate fluid padding, margins and gaps without manually solving viewport equations. Use one value, edit box-model sides, generate a complete scale or build custom spacing tokens. A schematic box model, real-width iframe and signed-value progression chart help you inspect the result. The editor processes settings locally in your browser and exports CSS that needs no JavaScript runtime or external service.
1Choose a spacing mode
Start with one CSS value, responsive padding, margin or gap, a complete spacing scale, or custom tokens. Pick an allowlisted physical or logical property.
2Configure viewports and endpoints
Set viewport bounds and a calculation root, then enter spacing at each endpoint. Values can increase or decrease. Convert between PX and REM without reinterpreting the numbers.
3Inspect the box and layout
Link or unlink sides, select diagram labels to edit them, change box sizing and compare real iframe widths. Use the numeric table and chart to inspect fixed, fluid or negative values.
4Export reusable code
Copy declarations, scoped classes, variables, layout CSS, stepped media queries, bounded calc, Tailwind v4 code or JSON tokens. Download standalone HTML and save editor configuration separately.
Responsive spacing adapts the distance inside or between elements to the available viewport. Fluid spacing changes continuously between two endpoint values; media-query spacing changes in steps. Use this generator for layout lengths rather than font sizing. Check spacing with real content and adjacent components instead of choosing numbers in isolation.
Slope = (ending spacing − starting spacing) / (maximum viewport − minimum viewport). Intercept = starting spacing − slope × minimum viewport. For 16px at 320px and 64px at 1440px, a 16px calculation root produces padding: clamp(1rem, calc(0.142857rem + 4.285714vw), 4rem). At 880px the result is approximately 40px. Increasing and decreasing values use sorted clamp bounds; negative coefficients use subtraction.
Padding adds space inside a border. Margin sits outside it and can depend on surrounding layout. Gap separates grid or flex items without adding outside space to the first or last item. Use padding-inline for container insets, margin-block for article rhythm and gap for a card grid. Padding and margin modes support linked sides, individual sides and copying values to an axis.
Negative margins and scroll margins require an applicable property and the explicit negative-value option. Negative padding, gaps and scroll padding are rejected. Auto is a separate fixed keyword for margins and is never placed inside clamp(). Auto margins consume available space according to layout; a numeric interpolation curve cannot describe that behavior.
The diagram labels margin, border, padding and content, including each physical side. Activate a side label to edit its control. With content-box, border-box width equals content width plus left/right padding and two borders. With border-box, the specified width includes padding and border, so the content area is reduced. Padding and borders can impose a minimum box size even when the specified width is smaller.
The controlled preview uses a flex container so margins do not collapse. Positive margins contribute to its reported outer occupied dimensions. Auto margins use free container space; negative margins are shown with signed labels and are not reduced to a misleading positive outer-size total. In normal document flow, collapsing margins, surrounding content and other layout rules can change the result. The diagram is schematic; the iframe demonstrates the actual CSS.
Four-point endpoints use positive base units divisible by four; eight-point endpoints use units divisible by eight. The scale follows 1, 2, 3, 4, 5, 6, 8, 10, 12 and 16 base units before continuing in eight-unit steps. Endpoint rounding must preserve the selected grid. Fluid intermediate values are not necessarily exact grid multiples.
Linear scales use base + step × increment. Modular scales use base × ratio raised to the step, with independent mobile and desktop ratios. Fibonacci-style scales use 1, 2, 3, 5, 8 and subsequent sums multiplied by a configurable base. Custom scales keep independently edited endpoints. Generated values must stay within ±2048px and remain valid for their mapped property. Unlike a font scale, valid spacing may decrease as the viewport grows.
Create up to forty tokens with unique IDs, variable names and classes. Use numeric, size-based or semantic naming with a configurable prefix. For example, define --space-md and apply padding-inline: var(--space-md). Bind layout roles such as section padding, card padding, grid gaps and form-field spacing to nonnegative numeric tokens. Negative and auto margins remain property-specific choices.
Logical properties follow writing mode and text direction. Padding-inline controls inline insets; padding-block controls the block axis. Start and end can map to different physical sides in RTL or vertical writing. The probe supports LTR, RTL and vertical writing modes so you can inspect that mapping. Logical side slots are labeled in the editor, while the diagram reports their resolved physical sides.
Clamp output interpolates continuously and stays at endpoint values outside the configured viewport range at the calculation root. Bounded calc uses media queries to cap the same linear expression. Media Queries output instead uses three fixed steps: starting, intermediate and ending. The intermediate breakpoint is editable. REM values respond to a reader’s root font size, so effective interpolation endpoints can move; production exports do not force a fixed root.
Place the generated @theme block after @import "tailwindcss". Variables such as --spacing-space-md create utilities including p-space-md and gap-space-md. Arbitrary-value examples preserve required spaces with underscores and use arbitrary-property syntax where a named utility is unavailable. Theme tokens include nonnegative numeric values; property-specific margin classes preserve negative and auto values without creating invalid padding tokens.
Copy generated class styles into a stylesheet and use className in React or Next.js. The spacing itself needs no client JavaScript. Keep existing server-owned metadata and content. In WordPress, enqueue the CSS through your theme or use its supported custom CSS interface, assign the generated classes and check for conflicts with theme spacing rules.
Test narrow viewports, long content, browser zoom, larger reader font defaults, focus visibility and text reflow. Fluid spacing alone does not guarantee accessibility. Avoid negative values on unsupported properties, interpolating auto, inverted viewport ranges, unconverted PX/REM switches, unintended side links and large scale steps that obscure content. The preview allows controlled scrolling for large examples without forcing page overflow.
Version 1 configuration JSON is limited to 256 KiB and forty tokens. Imports validate modes, nested fields, units, properties, numeric bounds, colors, identifiers and associations. Plain text is escaped and iframe previews run without script permissions. JSON design tokens use an InfinTools application-specific format rather than claiming standardized design-tool compatibility. Download CSS, JSON tokens, complete HTML or a separate configuration file.
- Responsive section and container padding
- Consistent card, navigation and form spacing
- Four-point and eight-point spacing design systems
- Logical spacing for multilingual layouts
- Comparing fluid spacing with stepped breakpoints
- Supports increasing, decreasing, fixed and explicitly enabled negative margin values.
- Six modes, six scale systems, forty editable tokens and twenty-four presets.
- Interactive box-model controls with calculated content and border-box dimensions.
- Local processing, real responsive previews and standalone code without added dependencies.
What is a CSS Responsive Spacing Generator?
It calculates responsive padding, margins, gaps and reusable spacing tokens from viewport and spacing bounds, with live layout and box-model previews.
What is fluid spacing in CSS?
Fluid spacing changes continuously between endpoint lengths as viewport width changes, commonly using CSS clamp().
How do I create responsive padding?
Choose Padding, link all sides or edit a side independently, and enter spacing at the minimum and maximum viewport widths.
How do I create responsive margins?
Choose Margin and edit the side values. Auto is available as a fixed keyword; negative values require explicit enablement.
How do I use CSS clamp for spacing?
Combine sorted lower and upper length bounds with a linear preferred expression. The tool calculates the intercept and viewport coefficient, including decreasing spacing.
What is the difference between padding and margin?
Padding creates space inside the border. Margin creates outside space whose behavior can depend on the surrounding layout and margin collapsing.
What is an eight-point spacing system?
It uses endpoint spacing values based on multiples of eight pixels. Fluid values between those endpoints need not remain multiples of eight.
What is a four-point spacing system?
It organizes endpoint spacing around multiples of four pixels, which can suit denser interface rhythms.
Can I generate responsive grid gaps?
Yes. Gap mode supports gap, row-gap and column-gap, with grid and flex layout demonstrations.
Can I generate negative margins?
Yes, for margin and scroll-margin properties after enabling negative margins. Negative padding, gaps and scroll padding are rejected.
What are CSS logical properties?
They express spacing using inline/block axes and start/end edges that follow text direction and writing mode rather than fixed physical sides.
Can I create a custom spacing scale?
Yes. Add up to forty editable tokens or start from four-point, eight-point, linear, modular or Fibonacci systems.
Can I generate CSS spacing variables?
Yes. CSS Variables output defines reusable properties and matching class rules. Prefixes and token names are editable.
Can I use fluid spacing in Tailwind CSS v4?
Yes. Export supported --spacing-* theme variables, property-specific classes or arbitrary-value examples. Theme variables are limited to nonnegative numeric spacing tokens.
Does responsive spacing require JavaScript?
No. The exported spacing and responsive layout behavior use CSS. This editor uses JavaScript only for calculation and interaction.
Can I use generated CSS in WordPress?
Yes. Add it through a supported theme stylesheet or custom CSS interface, assign its classes and inspect theme conflicts.
Can I export spacing design tokens?
Yes. Copy variables or download application-specific JSON tokens. Save configuration separately to reopen your editor settings.
Is the CSS Responsive Spacing Generator free?
Yes. Editing, previewing and exporting require no account or payment.