<style type="text/css">
* { margin:0; padding:0; }
.PicFrame { width:300px; height:200px; overflow:hidden; border:1px solid #000; }
.PicFrame { line-height:200px; position:relative; text-align:center; }
.PicFrame p { position:static; top:50%; vertical-align:middle; }
.PicFrame p { *position:absolute; } /* IE */
.PicFrame p img { position:static; top:-50%; left:-50%; vertical-align:middle; }
.PicFrame p img { *position:relative; } /* IE */
</style>
<div class="PicFrame"><p><img src="http://www.baidu.com/img/baidu_logo.gif" /></p></div>
IE 下说明:
一、DIV 对象(position:relative;),P 对象(position:absolute; top:50%;),这使 P 对象的左角是 DIV 对象的中心。
如下:
<div class="PicFrame"><p style="border:2px dotted red;width:100px;"></p></div>
二、IMG 对象(position:relative; top:-50%; left:-50%;)在 P 对象中,向左移动 50%,向上移动 50%,刚好使它的中心位于P 对象的左角,既是DIV对象的中心了。
如下:
<div class="PicFrame"><p><img src="http://www.baidu.com/img/baidu_logo.gif" /></p></div>



