如何居中 <table>
How to center a <table>
我有以下 css:
table.toe {
border: 1px solid black;
width: 80%;
margin-left:auto;
margin-right:auto;
}
table.toe td {
border:1px solid black;
text-align: center;
font-size: 24px;
}
我知道这会影响我的 table 因为宽度和 td 样式存在并且可以修改。但是 table 本身卡在屏幕的左侧,我希望它居中。
我正在使用 IE 9
谢谢!
除非您使用 Quirks Mode,否则自动边距将使 table 居中,这将导致 IE 9 模仿 IE 5。
确保您的 HTML 文档以 Doctype 开头。 HTML 5 通常是一个不错的选择。
<!DOCTYPE html>
通过 validator 也可能对 运行 代码有益。
我有以下 css:
table.toe {
border: 1px solid black;
width: 80%;
margin-left:auto;
margin-right:auto;
}
table.toe td {
border:1px solid black;
text-align: center;
font-size: 24px;
}
我知道这会影响我的 table 因为宽度和 td 样式存在并且可以修改。但是 table 本身卡在屏幕的左侧,我希望它居中。
我正在使用 IE 9
谢谢!
除非您使用 Quirks Mode,否则自动边距将使 table 居中,这将导致 IE 9 模仿 IE 5。
确保您的 HTML 文档以 Doctype 开头。 HTML 5 通常是一个不错的选择。
<!DOCTYPE html>
通过 validator 也可能对 运行 代码有益。