2010-04-08 9 views
32

CSSWarum nimmt TR keinen Stil?

table tr {border-bottom:1px solid #008999} 

HTML

<table width="100%" cellspacing="0" cellpadding="0"> 
    <thead> 
     <tr> 
     <th scope="col">one</th> 
     <th scope="col">two</th> 
     <th scope="col">three</th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
     <th scope="row">Hello</th> 
     <td>&nbsp;</td> 
     <td>&nbsp;</td> 
     </tr> 
    </tbody> 
</table> 
+0

Dubletten: http://stackoverflow.com/questions/670424/border-around-specific-rows-in-a-table http: // Stackoverflow. com/questions/583539/set-border-to-table-tr-funktioniert-in-allem-außer-ie-6-7 http://stackoverflow.com/questions/2238174/border-bottom-for-ie-en-is -nicht-working-in-tr –

Antwort

42

Anzahl:

table 
{ 
    border-collapse: collapse; 
} 

Ansonsten trcreates no single block.

Einfaches Beispiel:

table 
 
{ 
 
    border: 5px solid #900; 
 
    background: #fff; 
 
} 
 
tr 
 
{ 
 
    border: 5px solid #090; 
 
} 
 
td 
 
{ 
 
    background: #ccc; 
 
    padding: 5px 0; 
 
} 
 

 
table + table 
 
{ 
 
    border-collapse: collapse; 
 
}
<table> 
 
    <tr> 
 
    <td>def</td> 
 
    <td>ault</td> 
 
    </tr> 
 
</table> 
 
<table> 
 
    <tr> 
 
    <td>coll</td> 
 
    <td>apse</td> 
 
    </tr> 
 
</table>

+0

Zuerst haben Sie die Lösung gefunden, also akzeptiere ich Ihre Antwort –

+0

Warum muss es zusammengelegt werden? @toscho – Cullub

+0

@cullub Siehe den Satz unter dem Code-Block? – fuxia

8

Versuchen

table tr th {border-bottom:1px solid #008999} 

Dann geben Sie

table { border-collapse: collapse; } 
table tr {border-bottom:1px solid #008999; } 

Siehe verwenden The collapsing border model

+0

ich brauche auf tr nicht th –

+0

@ metal-gear-solid: Was genau willst du erreichen? Können Sie das visuelle Ergebnis beschreiben, das Sie sehen möchten? –

+0

@raul - siehe diese Tabelle tr {border-bottom: 1px solid # 008999} 'es bedeutet, dass jedes' TR' in 'table' mit 1px' height' solid' und in dieser Farbe '# 008999' begrenzt werden sollte. Was ist nicht klar? –

2

tr definitions wont Stile Grenze nehmen. Sie müssen es die TDs innerhalb sie anzuwenden:

table tr td {border-bottom:1px solid #008999}