我想找到一個解決方案,如何垂直對齊100%高度的div(我不知道它的高度)。在div中垂直對齊img,高度爲100%
我有這個HTML。我不能做與HTML不同的是加入更多的包裝:
<div id="wrapper">
<img src="http://www.lovecpokladu.cz/nalezy/9687/5.jpg" alt="" />
</div>
這相當固定的CSS - 初級我需要完成的圖像並非在所有瀏覽器中溢出瀏覽器窗口:
#wrapper {
position: absolute;
width: 100%;
height: 100%;
background: #ddd;
}
img {
max-width: 100%;
max-height: 100%;
}
非常感謝!
嗨。我在這裏回答:http://stackoverflow.com/questions/9915971/centering-an-image-on-screen-using-css-random-screen-image-dimensions/9916273#9916273 – mddw 2012-04-20 16:41:06