2
關於樣式化表格。我希望每一個奇數行都有一個特定的背景,除了包含頭部的第一行。如何使用:不是選擇器:類型爲n的
我用下面的代碼不工作:
.new-items-table tr:nth-of-type(odd):not(.new-items-table tr):nth-of-type(1)
{
background-color: red;
}
關於樣式化表格。我希望每一個奇數行都有一個特定的背景,除了包含頭部的第一行。如何使用:不是選擇器:類型爲n的
我用下面的代碼不工作:
.new-items-table tr:nth-of-type(odd):not(.new-items-table tr):nth-of-type(1)
{
background-color: red;
}
你爲什麼不換你的頭在標籤和表身在
標籤? – pkacprzak回答
一些選項:
~
selector - http://jsfiddle.net/5sKqX/它匹配
tr
S中的後其他tr
S,所以它跳過頭行。2.使用
<thead>
- http://jsfiddle.net/5sKqX/1/定製CSS:
3.使用
:not(:first-child)
- http://jsfiddle.net/5sKqX/2/來源
2013-08-18 12:26:06 Kobi
我測試了它。它看起來很棒。 〜工作人員很好,我總是想到這樣的字符串...很棒..謝謝 –
你可以這樣做:
2n + 1
是一回事odd
。2n + 3
跳過前兩行。演示:http://jsfiddle.net/YVTTA/
來源
2013-08-18 12:24:41 Blender
非常感謝。但是,在(奇數)關鍵字旁邊使用它有沒有可能的變化? –
@Mostafa:如果你在''和'
'中包裹頭部,你可以做'.new-items-table tbody tr:nth-child(odd)' – Blender哦,真好建議。再次感謝 –
正如我在你的問題的評論中寫道的那樣,在
<thead></thead>
和<tbody></tbody>
的表格正文中包裹了標題。然後,你可以簡單地使用以下規則:來源
2013-08-18 12:34:19 pkacprzak
好的解決方案,明白了 –
相關問題