CSS Sticky 定位解析
HTML 代码中,<div class="app-container"> 具有 overflow 自动滚动属性,这使得其成为 <div class="sticky-box"> 粘性定位的最近滚动祖先。因此,sticky-box 可以粘在 app-container 的顶部。
尽管 <sticky-box> 位于 <main> 之外,但由于粘性定位的特性,它仍然可以粘在 app-container 上。sticky 定位是在最近的具有滚动机制的祖先元素上生效的,而不是直接的父元素。因此,即使 <sticky-box> 不直接属于 app-container,它仍然会粘在它上面,因为它位于 app-container 的滚动块内。