【发布时间】:2014-01-13 23:18:10
【问题描述】:
我正在尝试使用最大宽度为 700px 的包装器构建一个页面
理想情况下,页面会响应并调整图像大小以适应窗口。我真的很难让浏览器调整图像和容器的大小以适应窗口高度。宽度似乎缩放得很好。最终,用户不必向下滚动即可查看该页面。如果没有 JavaScript,这可能吗?如果没有,有人可以指出我正确的方向吗?谢谢!代码如下:
jsfiddle:http://jsfiddle.net/LTchE/
<style type="text/css">
body, html {
height: 100%;
margin: 0px auto;
padding: 0px auto;
}
#wrapper {
height: auto;
min-height: 100%;
margin: 0px auto;
padding: 0px auto;
max-width: 600px;
background: #de291e;
}
.happyHolidays {
background: url('http://placehold.it/600x80') no-repeat center;
background-size: contain;
width: 90%;
height: 80px;
margin: 0 auto;
display: block;
}
.fromMe {
background: url('http://placehold.it/600x80') no-repeat center;
background-size: contain;
width: 90%;
height: 80px;
margin: 0 auto;
display: block;
}
.buttons {
text-align: center;
}
.snowperson {
text-align: center;
}
.snowperson img {
width: 100%;
}
</style>
</head>
<body>
<div id="wrapper">
<div class="happyHolidays"></div>
<div class="fromMe"></div>
<div class="snowperson">
<img src="http://placehold.it/650x750" name="snowperson" border=0>
</div>
<div class="buttons">
<a href="javascript:NextImage()">
<img src="http://placehold.it/150x50" alt="Next snowperson">
</a>
</div>
</div>
</body>
【问题讨论】: