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

2023-05-10,,

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中内容绝对居中(多行内容)的相关教程结束。

《css div中内容绝对居中(多行内容).doc》

下载本文的Word格式文档,以方便收藏与打印。