position: fixed 一定是相对于浏览器窗口进行定位吗?
参考答案
不一定。
默认相对视口定位,但若祖先元素创建了新的包含块,则会相对该祖先:
transform非 nonefilter/backdrop-filter非 noneperspective非 nonewill-change指定上述属性contain: paint/container-type
此时 fixed 元素被"捕获"在祖先内,滚动行为也随之改变(常见于弹窗被 transform 容器限制)。