concept
fixed-position-containing-block — CSS reference
A fixed-position box uses its nearest ancestor that establishes a fixed-position containing block; otherwise the layout viewport is used in continuous media. Transform is one trigger; layout or paint containment can also establish one.
Formal Syntax & Structure
css syntaxcss
transform: translateX(0); /* ancestor */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{margin:40px;transform:translateX(0)}#a{position:fixed;top:10px;left:20px}</style><body><div id="p"><div id="a">A</div><div id="b">B</div></div></body></html>