Aleix
Aleix

Reputation: 497

How to make this table only 1 pixel border?

I have this table:

image oftable

With the following code:

    <table border="1" id="comparativa">
        <tr>
            <td rowspan="2"></td>
            <td colspan="3" class="friuty">Fruity</td>
        </tr>
        <tr>
            <td class="lila">Intensed</td>
            <td class="lila">Medium</td>
            <td class="lila">Low</td>
        </tr>
        <tr>
            <td class="lila">Green</td>
            <td><img src="img/forsutpeque.png" /></td>
            <td><img src="img/donapeque.png" alt="" /></td>
            <td>-</td>
        </tr>
        <tr>
            <td class="lila">Mellow</td>
            <td>-</td>
            <td><img src="img/marpeque.png" alt="" /></td>
            <td>-</td>
        </tr>
        <tr>
            <td class="lila">Balanced</td>
            <td>-</td>
            <td><img src="img/cotxepeque.png" alt="" /></td>
            <td>-</td>
        </tr>
    </table>

and the following CSS

#comparativa { 
    width:350px; 
    font-size:1.2em; 
    border-spacing:0px; 
    border-collapse:separate; 
    empty-cells:hide !important; 
    border:0; 
}
#comparativa tr td { 
    padding:2px 4px; 
    border:#9f4dc2 solid 1px; 
    text-align:center; 
    width:88px; 
    color:#bdac77; 
}
#comparativa tr td.friuty { 
    background:#9f4dc2; 
    color:#fff; 
    text-transform:uppercase; 
}
#comparativa tr td.lila { 
    background:#ecdff3; 
    text-transform:uppercase;  
    color:#9f4dc2; 
    text-align:left; 
    padding-top:2px; 
    padding-bottom:4px; 
    padding-left:10px; 
}

I want to make it's inner borders 1px width while still keeping the empty top-left cell without showing the borders:

The problem is that if I put border-collapse:collapse then the top-left row appears with its border, even with the empty-cells:hide...

Any suggestion?

Upvotes: 7

Views: 7597

Answers (3)

Kwon
Kwon

Reputation: 390

Like so?

http://jsfiddle.net/apJkX/

Upvotes: 1

Edward Ruchevits
Edward Ruchevits

Reputation: 6696

You can specify override style for top left cell, using:

#comparativa tr:first-child td:first-child { border-left: 0; border-top: 0; }

Upvotes: 5

Alex Reynolds
Alex Reynolds

Reputation: 6352

try to give the table cell a class and set it's border-width to 0px.

Upvotes: 0

Related Questions