图片DIV居中
<style type="text/css">
.divCentre
{
/*
如果是单行文字想垂直居中
只要保证div高和行高保持一致
设置line-height与height相同值即可
让div的背景垂直居中:加center
还有注意重复属性:no-repeat
*/
width: 152px;
height: 176px;
line-height:150px;
text-align:center;
background: transparent url('http://my.poco.cn/items/images/user_set_bg_img.gif') no-repeat center;
}
</style>
<script language="javascript" type="text/jscript">
function imgFormatSize(obj)
{
//设置图片缩略,不产生变形
if(obj.width>130)
{
obj.width=130;
}
else if(obj.height>140)
{
obj.height=140;
}
}
</script>
<div class="divCentre">
<img onload="imgFormatSize(this)" src='http://www.cnblogs.com/skins/summerGarden/images/header.jpg' border="0"/>
</div>
---------------------用样式居中+图片框-------------------------
.photoimg img
{
border:1px #d8d8d8 solid;
background-color:#eaeaea;
padding:3px;
}