I have an unwieldy chunk of css that I am using to set the margin-top of the first child of an element. The first child can be any tag.
.comment-description p:first-child,
.comment-description ol:first-child,
.comment-description ul:first-child,
.comment-description pre:first-child,
.comment-description blockquote:first-child
{
margin-top:0px;
}
I'm sure that I can chop this down, but since I don't get to design too often, I can't remember a better way. Can I use something like:
.comment-description *:first-child
{
margin-top:0px;
}
Unfortunately this doesn't work.
You may be interested in:
.comment-description > :first-child {} - select only immediate children
or
.comment-description :first-child - select first child of all children elements
See:
http://jsfiddle.net/9VqsW/1/
To clarify things a little:
.element selector - selects all descendants that match selector. It doesn't matter if selector is a class, pseudo-class or ID..element > selector - selects only on the direct children that match selectorIt looks like you want:
.comment-description > :first-child{
....
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With