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

CSS - 有表親選擇器嗎?

CSS - is there a cousin selector?(CSS - 有表親選擇器嗎?)
本文介紹了CSS - 有表親選擇器嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

假設我有下表(JS Fiddle):

<table class="data-table">
<thead>
    <tr>
        <th scope="col">Method</th>
        <th scope="col">Price</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>Pickup*</td>
        <td>no charge</td>
    </tr>
    <tr>
        <td>Campus mail</td>
        <td>no charge</td>
    </tr>
</tbody>
<tfoot>
    <tr>
        <td colspan="2">* At 1st floor desk</td>
    </tr>
</tfoot>
</table>

TBODY 的行已使用 :nth-child(2n) 選擇器進行了斑馬條紋處理.但是 TFOOT 中行的背景沒有獲得這些樣式,并且只要表在 TBODY 中有偶數行,就會破壞偶數/奇數條帶.

The rows of the TBODY have been zebra striped using an :nth-child(2n) selector. But the background of the row in the TFOOT doesn't get those styles, and breaks the even/odd striping any time the table has an even number of rows in the TBODY.

我想選擇帶有 .data-table tbody tr:nth-child(2n):last-child + tr 之類的 TFOOT 行,但這不起作用.+ 選擇器用于共享單個父元素的相鄰兄弟元素.這里的兩個TR不是兄弟姐妹,他們是堂兄弟.

I'd like to select the TFOOT row with something like .data-table tbody tr:nth-child(2n):last-child + tr, but that won't work. The + selector is for adjacent sibling elements that share a single parent element. The two TRs here aren't siblings, they're cousins.

可以使用 jQuery(類似于 $(".data-table tbody tr:nth-child(2n):last-child").parent().next().find("tr").css({"background-color": "blue"})).但如果有的話,我更喜歡 CSS 解決方案.

I could use jQuery (something like $(".data-table tbody tr:nth-child(2n):last-child").parent().next().find("tr").css({"background-color": "blue"})). But I'd prefer a CSS solution if there is one.

那么,有沒有辦法選擇元素的表親?

So, is there any way to select an element's cousin?

推薦答案

CSS 在 DOM 中工作(盡管選擇器是向后處理的),因此您不能向上導航元素樹,然后再向下導航到元素的表親.您只能在同一級別的元素上操作(僅向前),或者向下.

CSS works down the DOM (although selectors are processed backwards), so you can't navigate up an element tree and then back down to reach an element's cousin. You can only either operate on the same level of elements (only going forward), or go down.

你必須使用你的 jQuery 解決方案.

You'll have to go with your jQuery solution.

這篇關于CSS - 有表親選擇器嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 選擇器的工具?)
主站蜘蛛池模板: 国产黄色大片 | 欧美一级片免费看 | 色视频一区二区 | 美女爽到呻吟久久久久 | 欧美伊人久久久久久久久影院 | 18av在线播放 | 国产综合在线视频 | 欧美久久一区二区三区 | 一级片在线免费播放 | 成人精品一区二区三区 | 放个毛片看看 | 成人在线视频看看 | 久久国品片 | 国产精品视屏 | 日韩国产在线 | 麻豆久久 | 欧美a在线看 | 亚洲高清视频一区二区 | 一区二区三区高清 | 亚洲va欧美va天堂v国产综合 | 九九综合 | 91久久久久久久久 | 午夜影院在线观看视频 | 精品国产青草久久久久福利 | 一区二区视频在线观看 | 黑人精品| 成人中文字幕在线 | 91在线观看免费 | 嫩草视频入口 | 一区二区三区电影网 | 免费观看的黄色网址 | 日日夜夜精品视频 | 欧美亚洲一区二区三区 | 欧美日韩国产在线观看 | av日韩高清| xxx视频| 成人国产在线观看 | 日韩免费视频一区二区 | 久久久蜜桃一区二区人 | 美女视频h | 国产剧情久久 |