开发者

css first-child selector help

Is there a way to highlight the first link, and only the firs开发者_StackOverflowt link, directly below a list item with class "selected"?

Here is my js fiddle


Yeah, use

.selected > a:first-child {
    /* CSS */
}

> limits the selector to direct children.


You can use the first-child selector.

.selected > a:first-child {
    color: red;
}

You can use nth-child() to do this as well.

.selected > a:nth-child(1) {
    color: red;
}  

or

.selected > a:nth-child(1n - 1) {
    color: red;
}

:)


.selected > a:first-child {color:red;}

This should work in your case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜