background-attachment: fixed not working on Safari

2019-09-06 15:55发布

I've got the following code running on an element that spans 100% of the browser:

#section_white {
  background-attachment:fixed;
  background-image:url(image_url_here.jpg);
  background-position:100% 100%;
  background-repeat:no-repeat no-repeat;
  background-size:cover;
}

What I need to do is to have the image span the entire width of the browser, while remaining fixed (thereby allowing the content to scroll on top of it).

It seems to work on all the browsers except Safari - any ideas what I'm missing?

I've tried setting the element height and min-height to 100%, with no joy.

A link to a demo page can be seen here: http://oscarsarc.tinygiantstudios.co.za/adopt/adopt-nationwide/

2条回答
SAY GOODBYE
2楼-- · 2019-09-06 16:20

Turns out Safari for Windows is no longer supported (how did I miss this?!) and the one I'm using is far too old to be useful. Using OSX / Safari, things look peachy (according to Benjamin)

查看更多
ら.Afraid
3楼-- · 2019-09-06 16:20

So this will help since background-size is partially supported in your version of safari you should use prefix just as below

html { 
  background: url(image_url_here.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

Try this and let me know any issues.

SOURCE LINK

CHECK BROWSER SUPPORT

查看更多
登录 后发表回答