我正在用jQuery Mobile开发一个Asp.Net MVC网站。
我有这个CSS部分,可以在滚动时将背景图片设置为固定在网站的中心:
background: white url(Image/A-HD.jpg);
background-repeat: no-repeat;
background-position: 50% 50%; /*or center center */
background-attachment: fixed;
background-size: 50%;
除iPad 2(我测试过的唯一一款)外,它可在所有地方使用。好像是背景固定:固定;固定。不能正常工作:背景图片实际上位于中心,但没有跟随我的滚动。
因此,有没有一种方法可以模拟背景附件:适用于iPad2(我想也是这样)?
谢谢!
最佳答案
您可以使用单独的元素和有效的position: fixed
解决此问题!
HTML:
<div id="Background"></div>
<div id="Content"></div>
CSS:
#Background {
background: white url(Image/A-HD.jpg) no-repeat 50% 50%;
background-size: 50%;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
关于ios - 如何模拟背景附加iPad,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/11473385/