第2种方法是否多余
第2种方法是在第1中方法的基础上(都是加table标签),额外加个display:inline,既然用第1种方法就能实现,为什么还要画蛇添足?
例如:下面代码加不加display:inline都能居中
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>不定宽块状元素水平居中</title>
<style>
table {
background-color: red;
margin: 0 auto;
}
#child {
display: inline;
}
</style>
</head>
<body>
<table>
<tbody>
<tr>
<td>
<div id="child">
我是子div中的第1行文本<br>
我是子div中的第2行文本<br>
我是子div中的第3行文本<br>
</div>
</td>
</tr>
</tbody>
</table>
</body>
</html>