Background size on iOS

前端 未结 2 718
-上瘾入骨i
-上瘾入骨i 2020-12-08 12:12

I\'ve spent the morning doing research on the following issue. I\'m making a one page site, using a lot of images. I\'m aware that Safari is known for its weird handling of

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-08 12:48

    Use another div with position:fixed to make the background fixed.

    Like this: http://codepen.io/anon/pen/OVebNg

    JADE

    .fixed
      .bgcover
    

    SCSS

    .fixed {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
      .bgcover {
          background-image: url('http://globe-views.com/dcim/dreams/winter/winter-04.jpg');
          background-size: cover;
        width: 100%;
        height: 100%;
      }
    }
    

    Hope this help.

提交回复
热议问题