问:如何让一个不固定高宽的图片,垂直和水平居中在页面中间?
目前的解决办法:
<div class="pannel">
<div class="ot">
<img src="http://www.wanggouchao.com/data/upload/custom/1304/17/516e585ba9b23.gif" />
</div>
</div>
<style>
.pannel{position:relative; border:1px solid red; margin:0 auto; width:600px; height:600px;}
.pannel .ot{ position:absolute; left:50%; top:50%; border:1px solid blue;}
.pannel .ot img{ position:relative; left:-50%; margin-top:-50%; }
</style>
转载于:https://blog.51cto.com/boss88/1226492