Quoting from the MDN docs on fixed
positioning (Oct 3 2018):
Let's now look at fixed positioning. This works in exactly the same way as absolute positioning, with one key difference: whereas absolute positioning fixes an element in place relative to the element or its nearest positioned ancestor, fixed positioning fixes an element in place relative to the browser viewport itself.
This statement seems to incomplete, because, as I recently figured out while browsing the answers to this question, the initial position of a fixed
element is horizontally determined with respect to the parent, not the viewport, if neither left
nor right
is set on the element, and is vertically determined with respect to the parent, not the viewport, if neither top
or bottom
is set on the element. Here's a fiddle: http://jsfiddle.net/7njh9fk4/2/.
Now I'm wondering if this behavior can be found documented somewhere, maybe alongside other quirks of position: fixed
.