MDN describes position: sticky;
as
Sticky positioning can be thought of as a hybrid of relative and fixed positioning. A stickily positioned element is treated as relatively positioned until it crosses a specified threshold, at which point it is treated as fixed until it reaches the boundary of its parent. For instance...
#one { position: sticky; top: 10px; }
...would position the element with id one relatively until the viewport were scrolled such that the element would be less than 10 pixels from the top. Beyond that threshold, the element would be fixed to 10 pixels from the top.
问题如果达到10px
的阈值,元素是否从文档流中取出
,从而使内容有点跳到顶部?
最佳答案
它不会,也不应该 - 这会破坏粘性定位的目的。如果它发生在某些浏览器中(它没有发生在我所知道的任何浏览器中),那么它就是一个错误,如果您报告它应该(并且将会)尽快得到修复,因为它可能会破坏一堆使用它的 Web 应用程序。
关于css - 粘性定位元素的内容是否从文档中取出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48410187/