How to keep the header static, always on top while scrolling?

前端 未结 8 794
被撕碎了的回忆
被撕碎了的回忆 2020-12-02 08:15

How would I go about keeping my header from scrolling with the rest of the page? I thought about utilizing frame-sets and iframes, jus

8条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 09:11

    .header {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 88px;
      z-index: 10;
      background: #eeeeee;
      -webkit-box-shadow: 0 7px 8px rgba(0, 0, 0, 0.12);
      -moz-box-shadow: 0 7px 8px rgba(0, 0, 0, 0.12);
      box-shadow: 0 7px 8px rgba(0, 0, 0, 0.12);
    }
    
    .header__content-text {
      text-align: center;
      padding: 15px 20px;
    }
    
    .page__content-container {
      margin: 100px auto;
      width: 975px;
      padding: 30px;
    }

    Header content will come here

提交回复
热议问题