Positioning Playground - Online Absolute & Relative Offset
Drag a positioned box and see the top/right/bottom/left values change. Understand containing blocks. Visual.
UD5 Toolkit
Interactive demo for position: sticky — headers, footers & stacked elements
Scroll down to see how sticky headers & footers behave
The position: sticky CSS property is a hybrid between relative and fixed positioning. An element with sticky positioning behaves like a relatively positioned element until the viewport scrolls to a certain threshold — then it "sticks" in place like a fixed element. This is incredibly useful for navigation bars, table headers, and persistent footers.
Position sticky is supported in all modern browsers including Chrome, Firefox, Safari, and Edge. It has been available since 2017 in most browsers. However, some older mobile browsers and IE11 do not support it. For those cases, a JavaScript polyfill or fallback to position: fixed may be necessary.
Unlike position: fixed, sticky elements respect their parent container's boundaries. They only stick within their containing block and do not overlap unrelated content. This makes them ideal for section headers, sidebar widgets, and in-content navigation without breaking the document flow.
You can stack multiple sticky elements by assigning different top values. For example, a sticky header with top: 0 and a sub-navigation with top: 60px will stack beautifully — the sub-nav sits right below the header when both are stuck. This is a popular pattern used by many SaaS dashboards and e-commerce sites.
Sticky positioning won't work if any ancestor element has overflow: hidden, overflow: scroll, or overflow: auto (unless that ancestor is the intended scroll container). Always check your DOM hierarchy when debugging sticky issues. The sticky element only sticks relative to its nearest scrolling ancestor.
Sticky footers using position: sticky; bottom: 0; are excellent for call-to-action bars, cookie consent notices, mobile checkout bars, and promotional banners. They appear at the bottom of the viewport while scrolling but remain within the document flow — a huge UX improvement over aggressive fixed footers.
When working with multiple sticky elements, z-index management becomes crucial. Headers typically need higher z-index values than content below them. Stacked sticky elements should have descending z-index values from top to bottom to ensure proper layering during scroll overlap.
Sticky positioning powers countless UI patterns: persistent navigation bars, floating table headers in data grids, sticky sidebars in blog layouts, anchored filter panels in search results, and "add to cart" bars in mobile product pages. Mastering sticky positioning unlocks cleaner, more performant UIs without JavaScript scroll listeners.
This is the bottom of the demonstration. The sticky footer above will remain at the bottom of the scroll container as you scroll. Thanks for exploring the sticky positioning playground!
position: sticky is a CSS positioning method that combines features of relative and fixed positioning. An element with position: sticky behaves normally in the document flow (like relative) until the user scrolls past a specified threshold (defined by top, bottom, left, or right). At that point, the element "sticks" to that position within its containing block — similar to a fixed element. The key difference is that sticky elements remain constrained within their parent container and do not escape the document flow entirely. This makes them perfect for navigation bars, section headers, table headers, and call-to-action footers.
overflow: hidden, scroll, or auto (other than the intended scroll container) will break sticky behavior.top, bottom, left, or right — otherwise the element won't know where to stick.align-items or justify-content properties on flex/grid parents can interfere with sticky positioning.-webkit-sticky prefix and can behave differently with sticky in table contexts.| Property | Sticky | Fixed |
|---|---|---|
| Document flow | Preserves space in flow | Removed from flow |
| Positioning context | Nearest scrolling ancestor | Viewport only |
| Parent boundary | Constrained by parent | No parent constraint |
| Scroll behavior | Sticks at threshold | Always fixed |
| Overlap handling | Natural, stays in container | Can overlap anything |
| Use cases | Headers, section bars, table heads | Floating buttons, modals, persistent bars |
top values. For example:
top: 0; z-index: 100;top: 60px; z-index: 99; (60px = header height)top: 110px; z-index: 98; (110px = header + sub-nav height)top value should equal the combined height of all sticky elements above it. Z-index should decrease from top to bottom to ensure proper occlusion. This technique is widely used in dashboards and complex web apps.
position: sticky is supported on iOS Safari (since iOS 6.1+ with -webkit-sticky) and all modern mobile browsers. However, there are some known issues:
-webkit-overflow-scrolling: touch. Using overflow: auto on the scroll container helps.<thead> and <th> elements. Using a wrapper div or polyfill may be necessary for complex tables.will-change: transform sparingly.position: sticky; top: 0; to <th> elements within a scrollable table container. However, note that some browsers (especially Safari) have inconsistent support for sticky on <thead>. A reliable workaround is to apply sticky directly to individual <th> cells rather than the <thead> row. For complex data grids, consider using position: sticky on both header rows and the first column for a冻结 (frozen) pane effect.
z-index carefully so sticky elements don't trap focus or hide interactive elements behind them.position: sticky is hardware-accelerated in modern browsers and generally performs better than JavaScript-based scroll-triggered fixed positioning. The browser's compositor thread handles sticky positioning natively, avoiding main-thread jank. However, excessive sticky elements (50+ on a single page) or sticky elements with complex box-shadow and backdrop-filter effects can impact scroll performance on low-end mobile devices. For optimal performance, keep sticky elements simple, use will-change: transform only when necessary, and test on target devices.
Drag a positioned box and see the top/right/bottom/left values change. Understand containing blocks. Visual.
Design a layout where nested grids share track sizes with their parent via subgrid. Copy the complete CSS.
Create a pure CSS scroll progress indicator using animation‑timeline: scroll(). No JavaScript. Copy the complete code.
Drop a WAV file and see its full header: sample rate, bit depth, channels, and chunk structure. Raw bytes explained.
Paste your CSS and see warnings for properties that have limited browser support. Links to CanIUse. Modernize safely.
Query the permission state of camera, microphone, geolocation, and more. See the response and learn the API.
Limit browser gestures on an element: pan‑x, pinch‑zoom, manipulation. Draw on a canvas to test. Mobile dev helper.
Acquire and release locks across tabs. Prevent race conditions in IndexedDB or localStorage. Visual queue and lock state.
Test the Fullscreen API: request fullscreen on a colored div, detect changes, and copy the JavaScript boilerplate.
Create complex linear gradients with any number of color stops, exact angles, and length units. Live preview and CSS code.
Style underlines, overlines, and strike-throughs with colors, wavy styles, and thickness. Modern CSS text‑decoration.
Design a button or card that glows on hover. Adjust shadow color, spread, and transition. Copy the CSS. Rich UI.
Create a realistic letterpress (debossed) text effect using CSS text‑shadow and background. Adjust depth and light direction. Copy code.
Generate a subtle noise/grain texture as a CSS background pattern. Adjust opacity and size. For that film look.
Create a customizable checkerboard or grid background using pure CSS gradients. Adjust cell size and colors. Copy the code.
Upload two images and apply CSS blend modes (multiply, screen, overlay, etc.). See the result and copy the filter CSS. Pure frontend.
Create a pure CSS countdown timer with a flipping number effect. Adjust duration and style. No JavaScript needed for display.
Create a glowing or rotating border animation around an element. Copy the CSS keyframes. Pure CSS magic.
Create a custom HTML/CSS progress bar with percentage, colors, and animation. Copy the code. Modern UI element.
Design a realistic neon sign text with multiple layers of glow. Copy the CSS and HTML. Perfect for headers.
A replica of the famous Flexbox Froggy game: solve alignment puzzles by writing CSS. Progress saved locally. Fun frontend learning.
Fetch a website's CSS and extract :root custom properties (‑‑color) to reveal its design token palette. For learning and inspiration.
Find safe mixing ratios for the classic elephant toothpaste demonstration. Volume adjustments for different container sizes.
Recreate the target CSS linear gradient by adjusting stops and colors. A unique game for front‑end developers to master gradients.
Browse and search all Font Awesome 6 icons with preview, class name, and unicode. Copy the HTML snippet. Perfect for web developers.
Create text with a gradient fill using CSS background-clip. Configure colors and direction. Copy the code. Works in modern browsers.
A complete, searchable list of all 140+ named HTML/CSS colors with their hex codes and color previews. Click to copy code. Essential web reference.
Visually experiment with Flexbox container and item properties. See the layout update in real time and copy the CSS. Learn by doing, fully interactive.
Minify JavaScript and CSS code to reduce file size for production. Remove whitespace and comments instantly. Run locally, your code stays private.
Easily create asymmetric border radius values and preview the result. Copy the generated CSS instantly. All interactively and browser-based.