吸顶效果实现

第一种 使用css 粘性定位 position: sticky; 属性实现 

<div class="topbox">
      这是顶部盒子
    </div>
.topbox {
    position: sticky;
    top:0;
    height: 30px;
    width: 100%;
    text-align: center;
    background:green;
  }

第二种 使用js,参考我的css中的 滚动动画类似

发布了107 篇原创文章 · 获赞 23 · 访问量 9万+

猜你喜欢

转载自blog.csdn.net/qq_42092177/article/details/103890296