You mentioned in the comments that OpenLayers uses CSS transforms. That being the case:
the element with fixed positioning will become relative to the element with the transform – not relative to the viewport
Take a look at the spec: The Transform Rendering Model
Specifying a value other than ‘none’ for the ‘transform’ property
establishes a new local coordinate system at the element that it is
applied to..wpr { width: 200px; height:1000px; background: pink; position:relative; margin: 0 200px; -webkit-transform: translateX(0); transform: translateX(0); } .fixed { width: 200px; height:200px; margin: 50px; position: fixed; top:0; left:0; background: aqua; }
<div class="wpr"> <div class="fixed"></div> </div>