我有一個相當簡單的CSS問題。簡單的CSS:格式化多個表
我想創建一個遵循特定格式的表格。我想在同一頁面上以不同的方式格式化多個表格。
我有這樣的:
CSS:
table.firstTable
{
border: 1px solid black;
}
td.firstTable
{
border: 1px solid black;
}
th.firstTable
{
border: 1px solid black;
background: #00003f;
font-color: #cfffff;
}
table.secondTable
{
border: 1px solid red;
}
td.secondTable
{
border: 1px solid red;
font-family: sans-serif;
}
th.secondTable
{
border: 1px solid red;
background: #cfffff;
font-color: #00003f;
}
唯一的辦法我就可以製作表格這種方式是一樣的東西:
HTML:
<table class="firstTable">
<tr>
<th class="firstTable">Item</th>
<th class="firstTable">Quantity</th>
<th class="firstTable">Price</th>
</tr>
<tr>
<td class="firstTable">0-001</td>
<td class="firstTable">Computer</td>
<td class="firstTable">$299.99</td>
</tr>
...
</table>
<table class="secondTable">
<tr>
<th class="secondTable">Customer ID</th>
<th class="secondTable">Total Sales</th>
</tr>
<tr>
<td class="secondTable">10001</td>
<td class="secondTable">$39.94</td>
</tr>
...
</table>
我知道有一個更好的方法來完成這個比co不斷重複「firstTable」和「secondTable」類。
我試圖做的事情是這樣的:
CSS:
#firstTable table
{
border: 1px solid black;
}
#firstTable th
...
然後
HTML:
<div id="firstTable">
<table>
...
</table>
</div>
,但沒有奏效。
我錯過了什麼?
謝謝!
請解釋您的修復程序的作用,而不是僅發佈修復程序。看着這個我不知道你在暗示什麼。 – Andrew
該修復程序是爲了響應原始文章。他解釋他在找什麼。 – netjunkie9