Fixed elements with no locations declared inherit static positions?
I've noticed that an element with position:fixed
, but no values declared for top
, bottom
, left
, or right
, gets positioned as though it w开发者_JS百科ere static, but does not scroll.
This is the case in every browser I've tested, and it's quite a useful thing to know, but I can't find any reference to this (after a brief search).
Basically, is this a bug or a feature?
From the horse's mouth...
...fixed boxes do not move when the document is scrolled.
Source.
To me, that sums up the behaviour that you are seeing. No matter where you position it, it will not scroll with the viewport.
精彩评论