在DIV中图片垂直、水平居中(最简单方法)

2009-04-17 10:21:07 by 【6yang】, 100 visits, 收藏 | 返回

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
.lanrentuku { 
  float: left; 
  text-align: center; 
  width: 150px; 
  height: 150px; 
  margin: 5px; 
  border: 1px solid #ccc; 
  font-size: 1em; 
  line-height: 148px; 
  } 

.lanrentuku img { 
  margin-top: e­xpression(( 150 - this.height ) / 2);  
  }
</style>
</head>

<body>


<div class="lanrentuku"> <img src="http://www.lanrentuku.com/images/uppic/200807160819430.gif" width="70" height="120" /> </div> 
<div class="lanrentuku"> <img src="http://www.lanrentuku.com/images/uppic/200807160819430.gif" width="90" height="80"  /> </div> 
<div class="lanrentuku"> <img src="http://www.lanrentuku.com/images/uppic/200807160819430.gif" width="70" height="120" /> </div>

<div style="clear:both"><br />代码整理:<a href="http://www.lanrentuku.com/" target="_blank">6yang图库</a></div>

<p></p>
</body>
</html>

分享到:
share

    图片原图

    loading

    loading