css all divs vs direct child divs

后端 未结 3 612
长情又很酷
长情又很酷 2020-12-09 14:36

I have this structure:

ffffdffffdd
pppppppppp
相关标签:
3条回答
  • 2020-12-09 15:02

    Actually I was searching this:

    Selects the divs that are direct children of Root:

    .Root > div {
        border: 1px solid red;
    }
    

    Selects all the divs under Root:

    .Root div {
        color:green;
    }
    
    0 讨论(0)
  • 2020-12-09 15:16
    .root {
    border: 1px solid green;
    }
    

    Why are you not declaring class /id for other divs?

    0 讨论(0)
  • 2020-12-09 15:22

    Something like this?

    .Root > :first-child, .Root > :last-child { border: 1px solid red }
    .Root { color: green; }
    

    Demo: http://jsfiddle.net/karim79/N5qFu/1/

    I would advise you to go through this: http://www.w3.org/TR/css3-selectors/

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