我制作了一个列中没有边框的表格,并且仅在行中给出了 1px 边框。

我使用了“边框折叠”属性,然后为所有行指定了 1 像素的边框。

然而我的问题是标题行比表格的其余部分长一点?

有谁知道我该如何解决它?

提前致谢。

html代码:

<!DOCTYPE html>
<html>
<title>web programming project 2</title>
<link rel="stylesheet" type="text/css" href="exe2CSS1.css">
<body>


<table class=outlined>
<tr id=headline>
<th class=side>Item</th>
<th class=side>Manufacturer</th>
<th class=side>Size</th>
<th class=center>Unit Price</th>
<th class=center>Quantity</th>
<th class=center>Total Price</th>
</tr>

<tr  class=firstCol>
<td class=side>Corn Flakes</td>
<td class=side>Kellogg's</td>
<td class=side>18 0z</td>
<td class=center>2.5</td>
<td class=center>1</td>
<td class=center>2.5</td>
</tr>


<tr class=secondCol>
<td class=side>Solid White Tuna</td>
<td class=side>Starkist</td>
<td class=side>5 oz</td>
<td class=center>2.79</td>
<td class=center>2</td>
<td class=center>5.58</td>
</tr>


</table>

</body>
</html>

CSS代码:

.outlined
{
font:13px Tahoma;
width: 75%;
border-collapse: collapse;
}

tr {
border: 1px solid white;
}

.secondCol{
background-color: #eeeff2
}

.firstCol{
background-color: #dfe1e7
}

.center{
text-align: center;
}

.side{
text-align: left
}

#headline{
background-color: #687291;
color: white;
}
有帮助吗?

解决方案

您缺少属性值周围的引号并且错过了结束语 </th> 在“总价”的第一行(您有一个 <th> 反而)

jsFiddle 演示

<tr id="headline">
    <th class="side">Item</th>
    <th class="side">Manufacturer</th>
    <th class="side">Size</th>
    <th class="center">Unit Price</th>
    <th class="center">Quantity</th>
    <th class="center">Total Price</th>
</tr>

其他提示

您好,您的最后一个标签未正确关闭”<th class=center>Total Price<th>"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top