久久久久久久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 選擇器的工具?)
主站蜘蛛池模板: 亚洲精品国产成人 | 国产成人精品一区二区三区在线 | 免费在线视频精品 | 成人网址在线观看 | 人和拘一级毛片c | 黑人巨大精品欧美一区二区免费 | 最新中文字幕在线 | 国产欧美精品一区二区色综合 | 国产一区2区 | 欧美成人精品一区二区三区 | 国产亚洲高清视频 | 韩国电影久久 | 超碰在线免费公开 | 欧美色性 | 九七午夜剧场福利写真 | 亚洲精品福利在线 | 欧美精品一区二区在线观看 | 国产一级片在线播放 | 91精品国产高清一区二区三区 | 一级a性色生活片久久毛片波多野 | 日韩三级免费观看 | 在线免费观看a级片 | 天天av天天好逼 | 色天堂影院 | av看片网| 国产在线观看网站 | 亚洲成人精品久久 | 亚洲视频免费在线观看 | 免费看一区二区三区 | 美女艹b| 亚洲成人一区二区 | 国产成人精品午夜视频免费 | 97av视频在线观看 | 无码一区二区三区视频 | 亚洲欧美在线一区 | 亚洲综合五月天婷婷 | 五月天婷婷丁香 | 成人免费精品视频 | 国产在线观 | 亚洲啪啪 | 在线免费观看a级片 |