久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

Zebra 使用 CSS3 對帶有隱藏行的表進行條帶化處理

Zebra striping a table with hidden rows using CSS3?(Zebra 使用 CSS3 對帶有隱藏行的表進行條帶化處理?)
本文介紹了Zebra 使用 CSS3 對帶有隱藏行的表進行條帶化處理?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一張桌子

<table id="mytable">
    <tr style="display: none;"><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr style="display: none;"><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
 </table>

我正在嘗試將表格條帶化設置為使用第 n 個子選擇器,但似乎無法破解它.

I'm trying to set the table striping to use nth-child selectors but just can't seem to crack it.

 table #mytable tr[@display=block]:nth-child(odd) { 
      background-color:  #000;  
 }
 table #mytable tr[@display=block]:nth-child(odd) { 
      background-color:  #FFF;
 }

我很確定我已經接近了......似乎無法破解它.

I'm pretty sure I'm close ... can't quite seem to crack it.

有人提供線索嗎?

推薦答案

這是你將要得到的最接近的.請注意,您不能讓 nth-child 只計算顯示的行數;nth-child 無論如何都會采用第 n 個子元素,而不是匹配給定選擇器的 nth 子元素.如果您希望丟失某些行而不影響斑馬條紋,則必須通過 DOM 或服務器端將它們從表中完全刪除.

Here's as close as you're going to get. Note that you can't make the nth-child count only displayed rows; nth-child will take the nth child element no matter what, not the nth child that matches a given selector. If you want some rows to be missing and not affect the zebra-striping, you will have to remove them from the table entirely, either through the DOM or on the server side.

<!DOCTYPE html>
<style>
#mytable tr:nth-child(odd) { 
      background-color:  #000;  
 }
#mytable tr:nth-child(even) { 
      background-color:  #FFF;
 }
</style>
<table id="mytable">
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
 </table>

以下是我所做的修復:

 table #mytable tr[@display=block]:nth-child(odd) { 
      background-color:  #000;  
 }

無需為基于 id 的選擇器指定祖先選擇器;只有一個元素會匹配 #table,所以你只是通過添加 table 來添加額外的代碼.

There's no need to specify an ancestor selector for an id based selector; there is only ever one element that will match #table, so you're just adding extra code by adding the table in.

 #mytable tr[@display=block]:nth-child(odd) { 
      background-color:  #000;  
 }

現在,[@display=block] 將匹配屬性 display 設置為 block 的元素,例如 .Display 不是有效的 HTML 屬性;你似乎想要做的是讓選擇器匹配元素的樣式,但你不能在 CSS 中做到這一點,因為瀏覽器需要應用 CSS 中的樣式才能弄清楚,這它在應用此選擇器時正在執行中.因此,您將無法選擇是否顯示表格行.由于 nth-child 無論如何只能取第 nth 個孩子,而不是帶有某些屬性的第 nth 個孩子,我們將不得不放棄這部分CSS.還有nth-of-type,它選擇相同元素類型的第n個子元素,但你只能這樣做.

Now, [@display=block] would match elements which had an attribute display set to block, such as <tr display=block>. Display isn't a valid HTML attribute; what you seem to be trying to do is to have the selector match on the style of the element, but you can't do that in CSS, since the browser needs to apply the styles from the CSS before it can figure that out, which it's in the process of doing when it's applying this selector. So, you won't be able to select on whether table rows are displayed. Since nth-child can only take the nth child no matter what, not nth with some attribute, we're going to have to give up on this part of the CSS. There is also nth-of-type, which selects the nth child of the same element type, but that's all you can do.

 #mytable tr:nth-child(odd) { 
      background-color:  #000;  
 }

你有它.

這篇關于Zebra 使用 CSS3 對帶有隱藏行的表進行條帶化處理?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Style every third element?(每隔三個元素設置樣式?)
Why shouldn#39;t I use ID selectors in CSS?(為什么我不應該在 CSS 中使用 ID 選擇器?)
What does img[class*=quot;alignquot;] mean in CSS?(CSS 中的 img[class*=“align] 是什么意思?)
CSS: Last element on line(CSS:最后一個元素)
How do I select every other div class element using just CSS (no js)(如何僅使用 CSS(無 js)選擇所有其他 div 類元素)
Tool for checking unused CSS selectors?(檢查未使用的 CSS 選擇器的工具?)
主站蜘蛛池模板: 欧美一级大黄 | 秋霞a级毛片在线看 | 极品国产视频 | 黑人巨大精品欧美黑白配亚洲 | 日韩有码一区二区三区 | 亚洲精品色 | 天天草视频 | 一区二区三区中文字幕 | 国产99久久久国产精品 | 亚洲精品4 | 精品一二区| 国产视频一区二区 | 国产精品久久久久久久久免费高清 | 欧美日在线 | 欧美一区二区三区久久精品 | 亚洲高清一区二区三区 | 中文字幕精品一区久久久久 | 欧美日韩成人影院 | 久久久久久国产精品 | 一区精品国产欧美在线 | 黄色日批视频 | 国产91在线观看 | 51ⅴ精品国产91久久久久久 | 草久久| 亚洲欧美日韩国产 | 在线视频一区二区三区 | 欧美一级免费片 | 在线观看的av | 国产精品久久久久久久久免费樱桃 | 国产激情一区二区三区 | 国产97视频在线观看 | 亚洲视频免费在线播放 | 丝袜一区二区三区 | 亚洲高清av | 日p视频免费看 | 99九九久久| 99久久婷婷 | 久久亚洲国产精品日日av夜夜 | a免费视频| 中文字幕在线一区 | 激情91|