CSS Position Playground
See how static, relative, absolute, sticky and fixed positioning behave — with live offsets, stacking order and copyable CSS.
Relative / absolute lab controls
Selected: Box ASticky boxes are at their natural position.
relative offsets the box from where it would normally sit; the space it occupied is reserved, and it becomes the containing block for absolutely positioned children. Containing block: its normal-flow parent — offsets do not apply.
Generated CSS
Relative / absolute lab · Box A selected.stage {
position: relative;
overflow: visible;
}
.box-a {
position: relative;
top: 20px;
left: 24px;
}
.box-b {
position: absolute;
top: 90px;
left: 80px;
z-index: 3;
}
.box-c {
position: static;
}All labs are independent: switching tabs keeps each configuration. Offsets are physical (top/right/bottom/left) even in RTL containers.
Examples
Static ignores top
Box C → static, top: 20pxThe offset input is disabled and no top declaration appears in the CSS paneOnly positioned boxes honor offsets; this is the most common CSS positioning surprise.
Absolute escapes its parent
Box B → absolute, turn off 'Parent has position relative'The containing-block caption names the nearest positioned ancestor outside the stageAbsolute boxes resolve against ancestors, not necessarily their immediate parent.
About this tool
CSS Position Playground is an interactive lab for the position property family: static, relative, absolute, sticky and fixed. Three boxes inside a containing block react live to top/right/bottom/left offsets, z-index and a parent-position toggle, and the equivalent CSS is always visible beside the stage.
The relative/absolute lab demonstrates why offsets are ignored on static boxes and how an absolute box can escape a parent that is not positioned. Boxes can be dragged with a pointer or nudged with arrow keys; each drag writes the physical top and left offsets and clears the opposing side so the emitted CSS is never over-constrained.
Two focused labs handle the confusing cases. The sticky lab uses an inner scroll container with a pin indicator, so sticky behavior is observable without scrolling the page. The fixed lab uses a dashed viewport frame to explain what fixed positioning anchors to and why a transformed ancestor can capture it. Explanatory notes call out stacking contexts, containing blocks and over-constrained axes. Everything runs locally with no uploads.
What this tool does not do
- The fixed lab simulates the viewport inside a dashed frame so it cannot cover the tool's own controls.
- Flexbox and grid alignment are out of scope; this lab isolates the position property family.
- Drag writes only top and left; right and bottom can still be set through the offset inputs.
- All state lives in the browser session; the labs are not saved when the tab closes.
How to use this tool
Pick a lab
Use the Relative / absolute, Sticky or Fixed tab. Each lab keeps its own state when you switch away and back.
Select and move a box
Click or focus a box, then drag it or use arrow keys (Shift for 10px steps). Static boxes deliberately ignore both.
Change the rules
Change a box's position value, its offsets and z-index, and toggle whether the parent is positioned to see the containing block change.
Copy the CSS
Read the emitted declarations in the CSS pane, review the explanations, and copy the snippet into your stylesheet.
Use cases
Learn positioning
See the difference between static, relative, absolute, sticky and fixed on the same three boxes.
Debug a layout
Toggle the parent's position to find out why an absolute box landed in the wrong place.
Teach stacking
Raise z-index on overlapping boxes and discuss when a stacking context is created.
Position values and their anchor
| Value | Offsets apply? |
|---|---|
| static | No |
| relative | Yes |
| absolute | Yes |
| sticky | Yes (top/left constrain) |
| fixed | Yes |
Offsets are physical: top/right/bottom/left do not flip in an RTL container.
Common mistakes
Mistake:Setting top on a static element and wondering why nothing moved.
Fix:Give it position: relative, absolute, sticky or fixed first.
Mistake:Assuming an absolute box is positioned relative to its parent.
Fix:Add position: relative to the intended containing block, or check the caption in the lab.
Mistake:Setting both top and bottom on an auto-height box.
Fix:Use one axis value; CSS ignores bottom in that case, and the lab shows a warning.
Frequently asked questions
Why does top/left not work on a static element?
Static is the default position value: the element stays in normal flow, so the CSS specification ignores its offsets and z-index. Change it to relative, absolute, sticky or fixed and the offsets take effect.
What is the containing block for an absolute element?
It is the nearest ancestor whose position is relative, absolute, fixed or sticky (or that has transform, filter or contain). If none exists, the initial containing block is used. Toggle the parent's position in the lab to watch the anchor change.
When does position create a stacking context?
A positioned element with a z-index other than auto creates a stacking context. Setting z-index on a static element has no effect, which is why that input is disabled in the lab.
Why doesn't position: sticky work?
Sticky needs a scrolling ancestor and a threshold such as top: 0. It also cannot stick outside its containing block. The Sticky lab supplies an inner scroll container so you can see the pin behavior directly.
What is the difference between fixed and sticky?
Fixed anchors to the viewport and ignores ancestor scrolling, while sticky only pins while its containing block is in view. A transformed or filtered ancestor can make fixed behave like absolute.
References & standards
Related tools
Aspect Ratio Calculator
Calculate dimensions and ratios for images and videos.
Border Radius Generator
Visually craft CSS border-radius values — including the advanced 8-value slash syntax for organic blob shapes — with a live preview and one-click copy.
Box Shadow Generator
Visual CSS box-shadow generator. Create beautiful shadows with live preview and copy the CSS code.
CSS :has() Selector Playground
Try the CSS :has() parent selector on live editable HTML and CSS, with ten patterns, dropped-rule detection and specificity notes.
CSS Button Generator
Design buttons with hover, active, focus-visible and disabled states — gradients, shadows, borders, icons — and copy clean CSS or Tailwind.
CSS Clip-Path Generator
Draw clip-path shapes visually: drag polygon points, tune circle/ellipse/inset presets, paste an SVG path and copy responsive CSS.