现在的位置: 首页 > 综合 > 正文

div中的文字垂直水平居中

2013年12月07日 ⁄ 综合 ⁄ 共 627字 ⁄ 字号 评论关闭
<!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></title>
<style type="text/css">
.wrap{
 background: #000;
 width: 500px; 
 height: 500px;
 color: #fff;
 display:table-cell;
 vertical-align: middle;
 float:right;
}
.verticalWrap{
 position: relative;
 top: 50%;
 +top: 100%;
}
.vertical{
 text-align: center;
 position: relative;
 top: -50%;
 +top: -50%;
}
</style>
</head>

<body>
<div class="wrap">
 <div class="verticalWrap">
  <div class="vertical">
   测试测试<br/>
   网页特效<br/>
  </div>
 </div>
</div>

</body>
</html>

抱歉!评论已关闭.