css边框没有显示但是应用了css

时间:2016-11-13 16:26:26

标签: html css html5 css3 border

我试图将边框应用于tr中的所有thead

的CSS(触笔):

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

根据chrome,应用了样式,但边框实际上并未显示: enter image description here

3 个答案:

答案 0 :(得分:1)

tr需要tableborder-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>

答案 1 :(得分: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>

答案 2 :(得分:0)

我不是css大师,但我通常在一行中写边框属性:

border: 10px solid #000;