做b站移动端的时候固定头部

188 阅读1分钟

固定头部导航栏:

header {
    //首先要把等级提高
    //要设置一下背景色,这样的话就可以挡住翻阅上来的页面
    z-index: 1;
    background-color: white;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: (84/3.75vw);
}

不加背景颜色的时候: 截屏2022-09-21 下午1.31.51.png

加了白色的背景颜色: 截屏2022-09-21 下午1.31.22.png