0
我想垂直和水平居中以寬度和高度可變的圖像,最大爲1000px。我歸檔垂直居中,但我無法添加水平中心在不破壞垂直...這裏是我的代碼:水平和垂直居中,大小可變,最大1000px寬度/高度;
<div style="margin-left:auto;margin-right:auto;width:70%;height:1000px;width:1000px;">
<div style="display:table-cell;vertical-align:middle;height:1000px;width:1000px;">
<img src="images/a.png">
</div>
</div>
看到這個答案:http://stackoverflow.com/questions/19843811/how-to-center-div-that-contains-an-image-within-a-div/19844070#19844070 –
太好了,但我需要做到這一點,而不需要觸摸body/html。 – ShadowHero
是否這樣? http://jsfiddle.net/VSe2J/ –