0

Just wondering, I got this:

.logblock:first-child {
    margin-top:4px;
}

.logblock.root .children .logblock:first-child {
    margin-top:0;
}

So the first of logblocks needs a margin-top of 4px unless its the first child of the root logblock

I tried various ways of incorporating :Not() into first selector so I wouldn't need the second one but couldn't figure it out. Is there a way?

user81993
  • 6,167
  • 6
  • 32
  • 64
  • seems like a dupe of [CSS negation pseudo-class :not() for parent/ancestor elements](https://stackoverflow.com/questions/7084112/css-negation-pseudo-class-not-for-parent-ancestor-elements), i.e. you need to select on the direct parent with `>`, otherwise there's always at least one ancestor that *is* the thing you don't want, so it blocks what you're trying to do. – underscore_d Nov 08 '17 at 17:08
  • Your prose doesn't reflect your css: if the `.logblock` is the first child of a `.logblock.root`, it is not a grandchild of it as the CSS says. So what is it? – Mr Lister Nov 08 '17 at 18:12
  • That said, isn't it easier to give the parent of the `.logblock`s a padding instead of giving the first `.logblock` a margin? – Mr Lister Nov 08 '17 at 18:14
  • _"I tried various ways of incorporating :Not()"_ so, why did you not post them, so readers don't waste their time suggesting things you already ruled out, or can explain why those failed and how to adjust them? – underscore_d Nov 08 '17 at 19:30
  • If I'm understanding you correctly, all you need here is `.logblock.root:first-child {margin-top: 0}`, no? Or is that `.children` selector there on purpose? (Sample HTML would help a lot.) – Daniel Beck Nov 08 '17 at 19:54

0 Answers0