如何删除表格间距

时间:2016-08-12 07:55:54

标签: html css css3 cell css-tables

我想删除当我在列上放两个数字时创建的间距。

这是小提琴代码:

Here is the fiddle link

这里有一些css:

table {
    width: 85%;
    margin: 0 auto;
    max-height: 400px;
    border-collapse: collapse;
} 

    table td {
        font-size: 14px;
        color: #fff;
        text-align: center;
        max-height: 20px;
        direction: rtl;
    }

    table th, td {
        padding: 7px;
    }

table.to th, td {
    padding: 0;
}    

2 个答案:

答案 0 :(得分:0)

您希望所有列的宽度相同吗?

table td {
    width:7%;
    font-size: 14px;
    color: #fff;
    text-align: center;
    max-height: 20px;
    direction: rtl;
}

//编辑:

body {
    margin: 0;
    padding: 30px;
    font-family: 'Source Sans Pro', sans-serif;
    direction: rtl;
    background-color:#000;
}

table {
    width: auto;
    margin: 0 auto;
    /*transform: scale(0.9);*/
    max-height: 400px;
    border-collapse: collapse;
}

    table th {
        color: #9ebbf3;
        height: 0.3%;
        background: linear-gradient(to bottom, rgba(57,71,82,0.4) 0%,rgba(40, 40, 52, 0.31) 100%);
        filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b3394752', endColorstr='#d6282834',GradientType=0 );
    }

    table td {
      padding: 0 20px;
        font-size: 14px;
        color: #fff;
        text-align: center;
        max-height: 20px;
        direction: rtl;
    }

    table th, td {
        padding: 7px;
    }

        table tr td:last-child {
            color: #ffdf32;
        }

               table tr th:last-child {
            color: #ffdf32;
            font-weight:500;
        }

table.to th, td {
    padding: 0;
}

table.to th {
    color: #ffdf32 !important;
    font-weight: 500 !important;
}

table tr {
    border:none!important;
}

table td {
    border-left: 1px solid;
    max-height: 20px;
    border-color: #425559;
}
 <table id="reTable" class="to" dir="ltr">
            <tr cellspacing="0">

                <th cellpadding="0">10</th>
                <th>999</th>
                <th>8</th>
                <th>7</th>
                <th>6</th>
                <th>5</th>
                <th>4</th>
                <th>3</th>
                <th>2</th>
                <th>1</th>
                <th>(1)1</th>
            </tr>
          

         
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>2</td>
                <td>1</td>
                <td>x</td>
                <td>4(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>1</td>
                <td>5(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>1</td>
                <td>x</td>
                <td>x</td>
                <td>1</td>
                <td>2</td>
                <td>1</td>
                <td>6(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>2</td>
                <td>x</td>
                <td>7(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>2</td>
                <td>1</td>
                <td>x</td>
                <td>1</td>
                <td>8(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>2</td>
                <td>1</td>
                <td>x</td>
                <td>1</td>
                <td>9(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>1</td>
                <td>2</td>
                <td>x</td>
                <td>x</td>
                <td>1</td>
                <td>1</td>
                <td>x</td>
                <td>x</td>
                <td>10(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>1</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>2</td>
                <td>11(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>x</td>
                <td>2</td>
                <td>1</td>
                <td>x</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>2</td>
                <td>12(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>x</td>
                <td>2</td>
                <td>1</td>
                <td>x</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>x</td>
                <td>x</td>
                <td>13(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>1</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>14(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>2</td>
                <td>x</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>15(1)</td>
            </tr>
            <tr>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>2</td>
                <td>x</td>
                <td>1</td>
                <td>x</td>
                <td>2</td>
                <td>x</td>
                <td>16(1)</td>
            </tr>

        </table>

答案 1 :(得分:0)

使用max-widthoverflow:hidden不允许th展开额外的空格!

N.B:这是为

完成的
  

我想删除当我在列上放两个数字时创建的间距。

因为你已经问过并使用数字,所以3可能溢出th的长度,因此溢出使用了

 table.to th {
        color: #ffdf32 !important;
        font-weight: 500 !important;
        overflow: hidden;
        max-width: 4px; //use max width as you prefer
    }

js fiddle link here