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

前端 未结 8 2321
温柔的废话
温柔的废话 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:51

    Why not use :empty?

    JQuery Empty

    EDIT: It also works as a CSS Selector:

    :empty { background-color: black; }
    

    MORE EDITS:

    :last-of-type almost works, but it gets 'a' for some reason. See my fiddle.

    http://jsfiddle.net/DUdVR/3/

    0 讨论(0)
  • 2020-11-28 15:56

    Depending on the number of divs you have you could either do something like:

    div#b.rowsLayout,div#d.rowsLayout,div#e.rowsLayout {}
    

    Maybe there is a better way to solve your problem, what are you trying to apply to all these divs?

    0 讨论(0)
提交回复
热议问题