- <style type="text/css">
- .container{
- text-align: center;
- border: solid 1px blue;
- }
- </style>
- <div class=container>
- <table>
- <tr><td>Text</td></tr>
- </table>
- </div>
在IE下"Text"居中显示,FF下"Text"靠左显示.
二、解决问题:
方案1:
- <style type="text/css">
- .container{
- text-align: center;
- border: solid 1px blue;
- }
- table {
- margin-left:auto;
- margin-right:auto;
- }
- </style>
- <div class=container>
- <table>
- <tr><td>Text</td></tr>
- </table>
- </div>
方案2:
- <style type="text/css">
- .container{
- text-align:-moz-center; /*FF*/
- #text-align: center; /*IE */
- border: solid 1px blue;
- }
- </style>
- <div class=container>
- <table>
- <tr><td>Text</td></tr>
- </table>
- </div>
方案3:
- <style type="text/css">
- .container{
- border: solid 1px blue;
- }
- </style>
- <center>
- <div class=container>
- <table>
- <tr><td>Text</td></tr>
- </table>
- </div>
- </center>
本文介绍了解决HTML表格在不同浏览器(IE与Firefox)中居中显示问题的三种方法,包括通过设置table的左右边距、使用特定浏览器前缀调整text-align属性以及采用HTML的<Center>标签。

1043

被折叠的 条评论
为什么被折叠?



