CSS table 上的样式居中对齐

CSS Style on table aligns to center

应用 table 样式后,table 居中对齐,它们不应该...为什么?

我可以为以下页面提供 HTML 文件... 这是一个截图:

    table.FLTT { 
        clear:both;
        width: 100%;
        margin: 0 auto;
        border-collapse: separate;
        border-spacing: 0;
        text-decoration: none;
        background: #fff;
        border:1px solid #dcdcdc;
        border-bottom:none;}

    table.FLTT th {
        background-color: #4D4D4d!important;
        color: #FFFFFF!important;
        padding: 10px 10px;
        text-decoration: none;
        transition: 0.0s;
        font-size: 13px;
        font-weight:normal;
        }

    table.FLTT td {
        padding: 5px 10px;
        border-bottom: 1px solid #dcdcdc;
        text-decoration: none;
        }

    table.FLTT tbody > tr:nth-child(odd) > td {
        background-color: #cccccc;
    }



    table.FLTT tbody tr:hover > td {
        background-color: #222222;
        color: #F0C237;
    }

    table.FLTT tr {
        text-decoration: none;
        -webkit-transition:all .5s ease;
        -moz-transition:all .5s ease;
        -o-transition:all .5s ease;
        transition:all .5s ease;}

    table.FLTT tr a {
        text-decoration: none;
        outline:none;
        color: #005689;
    }

    table.FLTT tr:hover a{
        background-color: #222222;
        color:#F0C237;
        text-decoration:underline;
    }

    table.FLTT tr.cat-list-row1 {
        background:#eee}

    table.FLTT thead th {
        color:#fff!important;
        background:#4D4D4d!important;}

margin: 0 auto; 部分在 table.FLTT{ } 中做到了这一点。您应该 post 一些 html 代码来确定,并将其放在上下文中。

在您的 table.FLIT{ } 代码中,您提到了 margin : 0 auto。 而不是此代码,元素将在父元素中居中。

在此 margin 属性 中,第一个值是距顶部的距离,第二个值是距左边界的距离。所以 auto 将使该元素居中。

您可以删除 属性 并设置为

margin : 0px 0px;

或再添加一个属性

float: left;

table.FLTT{}中的样式有margin: 0 auto;

这意味着顶部和底部的边距将分配给0,左右将分配为auto center

所以请删除margin:0 auto;