我对此稍作停留,以为我会分享这个position: sticky
+ flexbox陷阱:
在将视图切换到Flex Box容器之前,我的粘性div工作正常,并且当将div包裹在flexbox父级中时,div突然变得不粘性。
.flexbox-wrapper {
display: flex;
height: 600px;
}
.regular {
background-color: blue;
}
.sticky {
position: -webkit-sticky;
position: sticky;
top: 0;
background-color: red;
}
<div class="flexbox-wrapper">
<div class="regular">
This is the regular box
</div>
<div class="sticky">
This is the sticky box
</div>
</div>
position: sticky
或仅一个/某些浏览器上持续存在?