Fixed background image with ios7

2019-01-03 09:38发布

I have a project that I am using the fixed background image. It works great on everything except ios7. On the ipad the background image is zoomed in and blurry. Here is the CSS code I am using -

.header {
  display: table;
  height: 100%;
  width: 100%;
  position: relative;
  color: #fff;
  background: url(../images/boston2.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
  }

here is a link to the live page - www.wdeanmedical.com

What am I missing?

7条回答
Rolldiameter
2楼-- · 2019-01-03 10:40

Combining the ideas of @brouxhaha and @yllama: Use a media query that targets iOS, which is found at this SO post, to set

background-attachment: scroll;

This way the fixed background image appears for non-iOS mobile and all other devices.

.widget-wrap {
   background-attachment: fixed;
   ...
   ...
}

@supports (-webkit-overflow-scrolling: touch) {
  .widget-wrap {
  background-attachment: scroll;
  }
}
查看更多
登录 后发表回答