码迷,mamicode.com
首页 > Web开发 > 详细

css div中内容绝对居中(多行内容)

时间:2015-03-12 13:03:27      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

div中的内容绝对居中(不适合IE6哦,IE6我已经不考虑了),直接看代码吧。

<!DOCTYPE HTML>
<html>
 <head>
  <title>绝对居中 </title>
   <style type="text/css">
 h1, h2, h3, h4, h5 {
    margin:0px;
    padding:0px;
}
.panel {
    width:300px;
    height:150px;
    background:#000;
    color:green;
    display:table;
    float:left;
    margin-right:30px;
}
.absolute-center {
    vertical-align:middle;
    display:table-cell;
    text-align:center;
}
   </style>
 </head>
 <body>
 <div class="panel">
    <div class="absolute-center">
         <h1>LPJT</h1>
         <h5>(龙破九天)</h5>
    </div>
</div>
<div class="panel">
    <div class="absolute-center">
         <h1>XAJT</h1>
         <h5>(笑傲九天)</h5>
    </div>
</div>
 </body>
</html>

css div中内容绝对居中(多行内容)

标签:

原文地址:http://www.cnblogs.com/javaee6/p/4331955.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!