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.
Paste any iframe embed code (YouTube, maps) and get a responsive wrapper div with correct aspect ratio CSS.
Enter number of children and see estimated cups, plates, party favors needed. Quick planning tool for birthday parties.
Enter birth date and time to find your astrological moon sign. Based on simple zodiacal longitude. For entertainment.
Enter a number and see its ordinal representation in English, Spanish, French, etc. Localized rules.
Calculate the age of the moon in days since the last new moon. See illumination percentage. Simple algorithm.
Test the Fullscreen API: request fullscreen on a colored div, detect changes, and copy the JavaScript boilerplate.
See the View Transitions API in action. Cross‑fade and morph between two states. Copy the JavaScript starter code.
Visually configure scroll‑snap containers and items. Adjust alignment, stop behavior, and padding. Copy the clean CSS instantly.
Create complex linear gradients with any number of color stops, exact angles, and length units. Live preview and CSS code.
Design a light and dark theme by picking colors for backgrounds, text, and links. Get the CSS for both themes. Local.
Style underlines, overlines, and strike-throughs with colors, wavy styles, and thickness. Modern CSS text‑decoration.
Adjust opacity visually with a slider and see the different CSS representations (opacity property vs RGBA/HSLA). Copy best option.
Pick two images or colors and apply all 16 CSS mix‑blend‑mode values live. See and copy the right CSS for your design.
Design a fully styled scrollbar with colors, width, radius, and hover effects. Supports both ::-webkit‑scrollbar and Firefox scrollbar‑width.
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.
Paste your CSS and sort the properties of each rule alphabetically or by concentric groups. Keep your stylesheets consistent without a build step.
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.
Paste HTML/CSS snippets or enter properties to test how z‑index and stacking contexts interact. Real‑time example.
Adjust margin, border, padding, and content sizes interactively and see the rendered box model. Get the exact CSS. Teach or learn layout.
Create a glowing or rotating border animation around an element. Copy the CSS keyframes. Pure CSS magic.
Design a pure CSS tooltip with custom text, position (top/bottom/left/right), and arrow. Copy the clean code.
Create a custom HTML/CSS progress bar with percentage, colors, and animation. Copy the code. Modern UI element.
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.
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.