property-value
position/sticky — CSS reference
Maintains a normal-flow slot, then shifts inward from the nearest scrollport when an applicable non-auto inset would be violated, subject to its containing block. An ancestor with overflow hidden can change which scrollport is used. A sticky box creates a stacking context.
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>