如何让图片相对于上层DIV始终保持水平、垂直都居中



复制代码
代码如下:

<!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>
</body>
</html>

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3