我试图建立一个网页,一个包装,这将是最大宽度窗口高度:700像素调整大小容器,最大宽度
理想情况下,该网页将响应和调整图像以适合窗口。我真的很难让浏览器调整图像和容器的大小来适应窗口高度。宽度看起来很好。最终,用户不必向下滚动查看页面。这可能没有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>
虽然,目标是让容器垂直调整大小。因此,如果要调整视口的高度,则内容将根据视口的大小进行调整,并占用视口高度的100%,同时遵守包装器的宽度。您的示例在Chrome中看起来并不适合我。 – Pdnell
啊,很对。我没有完全让你的代码工作。如果你看看上面的第二个链接,它现在就可以工作。 更具体地说,容器#wrapper水平缩放,但它的内容溢出页面底部。如果要垂直缩放内容以使图像的中心位于浏览器的中心,我可以向您展示如何执行此操作。 – Mechame
是的,我们的目标是纵向扩展......它应该完全响应窗口大小。 – Pdnell