Can position:fixed be positioned relative to the parent element without setting top and left?

when I was looking at the layout of other people"s blogs, I found an interesting problem. Its sidebar was positioned with position:fixed, but it did not set the values of top and left. At this time, it was not positioned relative to the viewport, but relative to its parent element. I was very confused. I wonder if this usage is correct? And why is position:fixed doing this?

blog address

Jul.08,2022
The

location is called static position, which is where it was before it left the document stream. This will be used as the default value when no positioning is set.


if top left is not set, you can use margin positioning relative to the parent element, and the padding of the parent element is also useful, except that the element is detached from the document stream

  

absolute positioning, when left,top and other attributes are not set, it will be followed by the content of the parent element

Menu