background-attachment: fixed not working on Safari

混江龙づ霸主 提交于 2019-12-25 05:15:39

问题


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/


回答1:


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)




回答2:


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



来源:https://stackoverflow.com/questions/25972352/background-attachment-fixed-not-working-on-safari

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!