2015-04-26 68 views
0

终于得到我的主视差图像在背景大小:100%自动,但现在有一个很大的空白空间在div不缩放降至手机大小。请帮忙!这是site视差主图像的div高度将不会在移动设备上缩放

css 

.bcg { 
background-position: center center; 
background-repeat: no-repeat; 
background-attachment: fixed; 
background-size: 100% auto; 
height: 100%; 
width: 100%; 
} 

.hsContainer { 
display: table; 
table-layout: fixed; 
width: 100%; 
height: 100%; 
overflow: hidden; 
position: relative; 
} 

.hsContent { 
max-width: 450px; 
margin: -150px auto 0 auto; 
display: table-cell; 
vertical-align: middle; 
color: #ebebeb; 
padding: 0 8%; 
text-align: center 
} 
+0

使用'background-size:cover'应该在这种情况下效果更好... – Shikkediel

+0

我使用的是背景大小:封面,但图像的可笑程度非常大。有没有简单的方法来使分组响应? –

+0

您可以使用媒体查询为肖像或风景包含不同的背景图像。如果图像比率是固定的,我不知道如何在调整窗口大小时显示水平*或垂直中间。 – Shikkediel

回答

0

background-attachment:fixed;并不倾向于被移动浏览器支持。根据我的经验,这往往会导致一些不良行为。

这可能帮助:Background-attachment: fixed not working on android/mobile

另外:我觉得p标签是造成你的问题。检查元素显示P标签需要20-30px的高度。但没有内容。

+0

谢谢,我删除了p标签,没有任何改变。还添加了溢出标签,它使我的文本消失。虽然谢谢! –