html - 尽管使用边距 : 0 auto,Firefox 仍不使表格居中

标签 html css

以下 HTML 无法在 FireFox 中创建居中表格,尽管它可以在 Chrome 和 IE 中运行。我尝试过使用 margin: 0 auto 但这没有帮助。谁能帮我吗?

<html lang="en" class="no-js">
<head>
<meta charset="UTF-8">
<title>ICG Administrator Login</title>
<style type="text/css">
body {
    margin-bottom: 0px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0px;
}
h1 {
    border-bottom-width: 0px;
    border-left-width: 0px;
    border-right-width: 0px;
    border-top-width: 0px;
    color: #00377E;
    display: block;
    font-family: sans-serif;
    font-size: 26px;
    font-style: normal;
    font-variant: normal;
    font-weight: bold;
    height: 32px;
    line-height: 32px;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-right: 0px;
    margin-top: 0px;
    padding-bottom: 0px;
    padding-left: 0px;
    padding-right: 0px;
    padding-top: 0px;
    text-align: center;
    vertical-align: baseline;
}
table {
    -webkit-border-horizontal-spacing: 0px;
    -webkit-border-vertical-spacing: 0px;
    border: 1px solid #053F89;
    color: #444;
    display: table-cell;
    font-family: sans-serif;
    font-size: 13px;
    font-style: normal;
    font-variant: normal;
    font-weight: normal;
    line-height: 16px;
    margin-bottom: 0px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0px;
    padding-bottom: 0px;
    padding-left: 0px;
    padding-right: 0px;
    padding-top: 0px;
    position: static;
    vertical-align: top;
    white-space: normal;
}
</style>
</head>
<body>
<h1>Gateway and CDUE Administration</h1>
<div style="width: 100%; height: 50px; background-color: #053F89; background-origin: padding-box;"></div>
<DIV style="text-align: center;">
    <form method="GET" action="j_security_check">
    <BR>
        <table>
            <tr style="background-color: #053F89; font-weight: bold; color: white;">
                <td colspan=2>Log In</td>
            </tr>
            <tr>
                <td>User Name:</td>
                <td><input type="text" name="j_username" />
                </td>
            </tr>
            <tr>
                <td>Password:</td>
                <td><input type="password" name="j_password" />
                </td>
            </tr>
            <tr>
                <td colspan=2><input type="submit" value="Login" /></td>
            </tr>
        </table>
    </form></DIV>
</body>
</html>

最佳答案

去掉第 42 行,display: table-cell;

关于html - 尽管使用边距 : 0 auto,Firefox 仍不使表格居中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6578249/

相关文章:

html - HTML 中的 DOCTYPE 过渡

javascript - 在不刷新的情况下加载新页面时 CSS 加载缓慢

css - 防止 Twitter Bootstrap 空 <dd> 填充下一个 <dd> 值

css - 我怎样才能快捷颜色#F4F4F4?

html - 文本区域中的文本颜色 Bootstrap

javascript - 如何在 Bootstrap 中制作粘性侧边栏?

python - Ubuntu 中的 header 、用户代理、Url 请求

css - 我可以制作带圆 Angular 的表格线吗?

CSS3 多背景图片不工作

jquery - CSS 命名空间和覆盖 jquery 选择器