首页 > Web开发 > 详细

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

时间:2016-01-31 00:30:02      阅读:136      评论:0      收藏:0      [点我收藏+]

复制代码
代码如下:

<!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>

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

原文:http://www.jb51.net/css/97506.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!