解决兼容性的方案 https://github.com/wilddeer/stickyfill
// 对于支持sticky的浏览器直接使用CSS吸顶效果,否则使用Stickyfill模拟吸顶解决兼容问题
if ( !('CSS' in window && CSS.supports && CSS.supports('position', 'sticky')) ) {
Stickyfill.add( document.querySelectorAll('.stickey') );
}
.stickey{
position: -webkit-sticky;/* Safari */
position: sticky;
top: 0;
z-index: 2;
}