您的位置:首页 > 其它

使图片相对于上层DIV始终水平、垂直都居中

2013-08-11 18:38 465 查看
<!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=utf-8" />
<title>使图片相对于上层DIV始终水平、垂直都居中</title>
<style type="text/css">
.thumbBox {width:260px; height:260px; text-align:center; vertical-align:middle; display:table-cell; border:1px solid red;}
</style>
</head>

<body>
使图片相对于上层DIV始终水平、垂直都居中
<p>示例一</p>

<div class="thumbBox">
<img src="http://www.baidu.com/img/bdlogo.gif" >
</div>

<p>示例二</p>

<div class="thumbBox">
<img src="http://y2.ifengimg.com/mappa/2013/06/03/cb32ecdc7d0def4d123ae4c38c50050b.jpg" >
</div>

<p>查找更多代码,请访问:<a href="http://www.lanrentuku.com" target="_blank">懒人图库</a></p>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: