2013-03-26 95 views
0

我试图解决我的网站的背景,我有地方有我的网站上一个div“bgDiv”的位置固定。它在桌面上运行良好。但在iPad上固定的位置不工作,它与我的整个网站滚动。和背景图像重复。有什么办法可以避免滚动bgDiv。位置固定不工作在iPad

.bgDiv{ 
    background: url("test.jpg") repeat scroll 0 0 transparent; 
    background-size: 100% 100%; 
    bottom: 0; 
    left: 0; 
    position: fixed; 
    right: 0; 
    top: 0; 
    z-index: -2; 
    height: inherit; 
    } 

<body> 
    <div class="bgDiv"></div> 
    <div class="wrapper"> 
      content 
     </div> 
</body> 
+0

可能重复:http://stackoverflow.com/questions/4408363/fixed-position-not-working-on-ipa d?RQ = 1 – FoolishSeth 2013-03-26 06:51:50

回答

1

更新你的CSS与此,

.bgDiv{ 
    background: url("test.jpg") repeat scroll 0 0 transparent; 
    background-size: 100% 100%; 
    left: 0; 
    position: fixed; 
    top: 0; 
    z-index: -2; 
    height: auto; 
    width:100%; 
} 

如果不添加,将它添加到你上面的代码中,

<meta name="viewport" content="width=device-width, user-scalable=no" /> 

您可以参考这个文档: - http://www.quirksmode.org/blog/archives/2010/12/the_fifth_posit.html

+0

我已经添加了这个元标记,但它不工作。谢谢 – 2013-03-26 07:34:49