如何在HTML表格中向单元格边框添加定义?

时间:2014-01-17 21:50:03

标签: html html-table

此表:

<table border="1">
<tbody><tr>
<td></td>
<td>Grokkability</td>
<td>PIA Factor*</td>
<td>FancyPantsiness</td>
</tr>
<tr>
<td>XML</td>
<td>10</td>
<td>8</td>
<td>2</td>
</tr>
<tr>
<td>Code</td>
<td>10</td>
<td>5</td>
<td>4</td>
</tr>
<tr>
<td>Auto-Wiring</td>
<td>2</td>
<td>2</td>
<td>10</td>
</tr>
</tbody></table>

...在jsfiddle(http://jsfiddle.net/clayshannon/9AX8H/)看起来像我想要的那样,但在Code Project上它已经丢失了它的单元格格式(http://www.codeproject.com/Tips/711127/Swapping-Out-Concrete-Implementations-of-Interface

我该怎样做才能强制细胞边界可见?

1 个答案:

答案 0 :(得分:1)

您可能想要使用css ..

<table class="border">
<tbody><tr>
<th></th>
<th>Grokkability</th>
<th>PIA Factor*</th>
<th>FancyPantsiness</th>
</tr>
<tr>
<th>XML</th>
<td>10</td>
<td>8</td>
<td>2</td>
</tr>
<tr>
<th>Code</th>
<td>10</td>
<td>5</td>
<td>4</td>
</tr>
<tr>
<th>Auto-Wiring</th>
<td>2</td>
<td>2</td>
<td>10</td>
</tr>
</tbody></table>

Your css

.border {
    border: solid 1pt;
    border-collapse:collapse;
}

.border th{
border: 1px solid #000000;
    padding: 4px;
    background-color: #34B767;
}

.border td{
border: 1px solid;
    padding: 4px;
}

enter image description here