我想制作一个名为"类别中的最近帖子";,在这个页面上显示为粘性,所以当用户向下滚动时,它保持固定。
由于affix
在Bootstrap 4中被删除,我尝试了CSS方法,并在codepen上找到了一个在浏览器中运行良好的示例。我在css文件中添加了以下代码:
.make-me-sticky {
position: -webkit-sticky;
position: sticky;
top: 0;
}
并且该类被添加到htmldiv
<div class="col-md-12 col-lg-4 sidebar make-me-sticky">
但我看不出有什么效果。怎么了?
.make-me-sticky {
position: fixed;
top: 0;
right: 0;
overflow: hidden;
height: 100vh;
}