concept

sticky-view-rectangle — CSS reference

Sticky insets define a view rectangle relative to the nearest scrollport. Auto is treated as zero for this rectangle calculation. If the rectangle is smaller than the sticky border box, the effective end inset is reduced as required. Actual shifts remain limited by the containing block.

Formal Syntax & Structure

css syntaxcss
position: sticky; top: 10px;

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>CSS positioning lab</title><style>body {margin:0} .sample {background:#dcebe9;color:#182e32}#p{width:240px;height:160px;background:#e6eef2} #a{width:60px;height:30px;background:#128579} #b{height:20px;background:#adcde8}#p{overflow:auto;height:100px}#a{position:sticky;top:10px}</style><body><div id="p"><div style="height:50px"></div><div id="a">Sticky</div><div style="height:300px"></div></div></body></html>
CSS Reference