sw0o0sh
sw0o0sh

Reputation: 77

HTML table moving to center

I have problem with my html table. I'm trying to move it to middle, but it keeps moving right. I have tried many different ways, but this is, what I have done so far:

<style type="text/css">


table.gridtable2 {
    font-size:11px;
    border: none;
}
table.gridtable2 th {
    padding: 7px;
    color:#008CBD;
    background: rgba(0,0,0,0.3);

}
table.gridtable2 td {
    padding: 6px;
        color:#FFFFFF;
    background: rgba(0,0,0,0.2);
}
table.gridtable2 tr {
    text-align: center;
}
</style>

    <table class="gridtable2" width="539" cellspacing="0" cellpadding="0">
        <tr>
            <th></th>
            <th>Title</th>
            <th></th>
        </tr>
        <tr>
            <td>Sold</td>
            <td>-</td>
            <td>0€</td>
        </tr>
        <tr>
            <td>Else</td>
            <td>-</td>
            <td>0€</td>
        </tr>
        <tr>
            <td>Total</td>
            <td>-</td>
            <td></td>
        </tr>
    </table>

Upvotes: 0

Views: 540

Answers (2)

Kintarō
Kintarō

Reputation: 3187

You should use margin-left and margin-right set as auto.

<table style="width=50%;margin-left:auto; margin-right:auto" width="539" cellspacing="0" cellpadding="0">
    <tr>
        <th></th>
    <th>Title</th>
    <th></th>
</tr>
<tr>
    <td>Sold</td>
    <td>-</td>
    <td>0€</td>
</tr>
<tr>
    <td>Else</td>
    <td>-</td>
    <td>0€</td>
</tr>
<tr>
    <td>Total</td>
    <td>-</td>
    <td></td>
</tr>
</table>

Upvotes: 0

rlatief
rlatief

Reputation: 723

table.gridtable2 {
    font-size:11px;
    border: none;
    margin: 0 auto;
}

Upvotes: 2

Related Questions