CSS Selectors - Selecting a specific child element

后端 未结 2 1304
死守一世寂寞
死守一世寂寞 2021-01-14 14:16

Here is my code snippet:

2条回答
  •  悲哀的现实
    2021-01-14 14:42

    With CSS3's :nth-child() it's easy to fulfill the "specific" criterion:

    #shopping-cart-totals-table > tbody > tr:nth-child(2) > td:nth-child(2) .price
    

    Or, an alternative that works more in favor of browser compatibility (does not use CSS3 selectors, assumes exactly two trs and two tds):

    #shopping-cart-totals-table > tbody > tr + tr > td + td .price
    

提交回复
热议问题