我正在尝试设置一个流畅的模板,我也可以将其用于响应式设计视口(viewport)。但是现在,当我尝试调整浏览器窗口大小时,它不会缩放,而在我的 iPhone 上,我只能看到标题图形的左上部分。我有一个主包装背景和一个标题动画 gif,它们的宽度都是 1200 像素。任何帮助将不胜感激。
视口(viewport)
<meta name="viewport" content="width=device-width, initial-scale=1">
CSS
body {
background-color: #B28D66;
margin: 0 auto;
}
#Wrapper {
max-width:1200px;
width:95%;
background-image: url(../img/background_main.jpg);
background-repeat: no-repeat scroll;
background-position: center top;
height: 2200px;
position: relative;
margin-top: 0;
margin-right: auto;
margin-bottom: 0;
margin-left: auto;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#Wrapper #Banner {
width: 100%;
height: 350px;
background-image: url(../img/animated-gif-header.gif);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
#Wrapper #Content {
width: 75%;
margin: 0 auto;
}
#Wrapper #MainNav {
background-image: url(../img/nav_bar.png);
width: 100%;
height: 75px;
margin-top: -20px;
}
#Wrapper #MainNav ul {
margin-right: 100px;
}
#Wrapper #MainNav ul li {
float: right;
margin-top: 15px;
padding-right: 21px;
最佳答案
尝试按以下方式使用 background-size 属性:
background-size:100% auto;
如果你想让它的高度覆盖整个页面高度,或者使用下面的
background-size:auto 100%;
关于css - 如何使 css 背景图像随窗口大小和设备缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15588091/