CSS selector to get deepest element of specific class in the HTML tree

前端 未结 8 2339
温柔的废话
温柔的废话 2020-11-28 14:49

I\'ve got a a bunch of DIV elements in my HTML, several of which have their class attribute set to \"rowsLayout\". Some of these rowsLayout DIVs can be nested inside one an

8条回答
  •  伪装坚强ぢ
    2020-11-28 15:47

    You can use the jQuery selector .rowsLayout:not(:has(.rowsLayout)).

    However, for performance reasons, this is not possible in CSS.

    Your selector depends on the children (or lack thereof) of the elements that you target.
    CSS is designed so that an element's selectors can always be resolved before the element's children exist; this allows CSS to be applied as a document loads.

提交回复
热议问题