9

There is a parent div with id = "cooldiv". It has many div elements inside. Now I need to set a css property to all the child div-s except the first one.

So, this is what I've tried so far to accomplish this task:

#cooldiv .row:not(first-child) {
    top: -50px;
}

But, of course, it didn't work out. What's wrong here? This is the screenshot of the source code:

enter image description here

curveball
  • 4,320
  • 15
  • 39
  • 49
TyForHelpDude
  • 4,828
  • 10
  • 48
  • 96

2 Answers2

31

Try #cooldiv .row:not(:first-child). It seems you missed : before first-child. Maybe that's why it doesn't function?

curveball
  • 4,320
  • 15
  • 39
  • 49
  • yeah but still not works – TyForHelpDude Apr 07 '17 at 15:05
  • What do you mean? The selectors itself should work fine. But you for sure have more code there, so your styles `top:-50px` may be rewritten. Also, `top:-50px` will not work per se - the element should be positioned (relative, absolute etc.) You might need to use `margin-top:-50px` instead. It is hard to say more since very small part of your code is exposed here. – curveball Apr 07 '17 at 16:06
  • ok ok it works here :) – TyForHelpDude Apr 07 '17 at 16:56
1

Try something like that

#cooldiv .row:first-child {
    top:0px;
} #cooldiv .row {
    top:-50px;
}