css - 粘性定位元素的内容是否从文档中取出?

标签 css

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/

相关文章:

javascript - 我如何获得一个按钮来更改样式表、保存到本地存储并出现在网站的所有页面上?

javascript - 尝试使用基于内容高度自动扩展和收缩的文本区域创建 React 组件(使用 Sandbox)

html - 50% 宽度两列 css

html - 行内元素的顶部边距

php - 登录标题不起作用

html - 将下拉箭头移动到链接元素的右侧

javascript - 为什么 document.execCommand 不会导致剪贴板填充?

HTML 页面移动(不是滚动条问题!)

css - @font-face 不在服务器上时在 IE 中不工作

javascript - 为什么我的引导模式不会弹出?