文本,图片,水平,垂直居中

<!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">
.wrap
{
text-align
:center;
width
:500px;
height
:500px;
background-color
:#0F9;
vertical-align
:middle;
display
:table-cell;/*非IE6*/
position
:relative;
}
.wrap2
{
*position
:absolute;
*top
:50%;
*left
:50%
}
.con
{
width
:270px;
*position
:relative;
*top
:-50%;
*left
:-50%;
border
:1px solid #000;
display
:inline-block;

}
img
{ /*图片放入DIV中IE6下,有下边距BUG的3中解决方法 vertical-align:bottom 或 font-size:0 或*/ display:block;}
</style>
</head>
<body>
<div class="wrap">
<div class="wrap2">
<div class="con">
<a href="#">居中居中居中居中居中居中居中居中居中居中居中居中居中居中</a><img src="http://www.baidu.com/img/baidu_logo.gif" /></div>
</div>
</div>
原文地址:https://www.cnblogs.com/bennman/p/1955168.html