<!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">
<!--
.a1 {
background-color: #CC99CC;
height: 50px;
width: 700px;
text-align: center;
font-size: 24px;
line-height: 50px;
font-weight: bold;
}
-->
</style>
</head>
<body>
<div class="a1">此处显示 class "a1" 的内容</div>
</body>
</html>
结果显示:
文本垂直居中的关键:
<strong><span style="font-size:18px;"> line-height的值与height的值相同</span></strong>