2016-11-13 5 views
0

Я пытаюсь применить границу для всех tr в thead.css border not show, но css применяется

Css (стилус):

table 
    thead 
     tr 
      border: solid #000; 
      border-width: 0 10px; 

По хрому стили получить применяется, но граница фактически не появляется: enter image description here

+0

ссылка: -http: //www.w3schools.com/tags/tryit .asp? filename = tryhtml_tbody –

+0

Попробуйте применить к 'table' или' td'. Это работает? –

+0

'' '' '' '' '' '' '' '' '' '' 'border-collapse: collapse' для границы для работы ... и когда это не может быть использовано, установите его на' td' – LGSon

ответ

1

tr нужно его table иметь border-collapse: collapse для границы, чтобы работать

table.first { 
 
    border-collapse: separate;  /* property default */ 
 
} 
 
table.second { 
 
    border-collapse: collapse; 
 
} 
 

 
table thead tr { 
 
    border-bottom: 2px solid gray; 
 
} 
 

 
/* for this demo only */ 
 
div { 
 
    margin: 25px 20px 10px; 
 
    text-decoration: underline; 
 
}
<div>This table's tr (in thead) has no border</div> 
 

 
<table class="first"> 
 
    <thead> 
 
    <tr> 
 
     <td>Left Head</td> 
 
     <td>Right Head</td> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
    <tr> 
 
     <td>Left</td> 
 
     <td>Right</td> 
 
    </tr> 
 
    </tbody> 
 
</table> 
 

 
<div>This table's tr (in thead) has border</div> 
 

 
<table class="second"> 
 
    <thead> 
 
    <tr> 
 
     <td>Left Head</td> 
 
     <td>Right Head</td> 
 
    </tr> 
 
    </thead> 
 
    <tbody> 
 
    <tr> 
 
     <td>Left</td> 
 
     <td>Right</td> 
 
    </tr> 
 
    </tbody> 
 
</table>

+0

Это сработало, спасибо! : D – g3mini

0

thead {color:green;} 
 
tbody {color:blue;} 
 
tfoot {color:red;} 
 

 
table, th, td { 
 
    border: 1px solid black; 
 
}
<table> 
 
    <thead> 
 
    <tr> 
 
     <th>Month</th> 
 
     <th>Savings</th> 
 
    </tr> 
 
    </thead> 
 
    <tfoot> 
 
    <tr> 
 
     <td>Sum</td> 
 
     <td>$180</td> 
 
    </tr> 
 
    </tfoot> 
 
    <tbody> 
 
    <tr> 
 
     <td>January</td> 
 
     <td>$100</td> 
 
    </tr> 
 
    <tr> 
 
     <td>February</td> 
 
     <td>$80</td> 
 
    </tr> 
 
    </tbody> 
 
</table>

0

Я не мастер css, но я обычно пишу свойства границы i п одна строка:

border: 10px solid #000;