CSS:将背景颜色应用于ul li菜单的第一个孩子 [英] CSS: apply background color to first-child of ul li menu

查看:240
本文介绍了CSS:将背景颜色应用于ul li菜单的第一个孩子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要应用红色背景颜色第一li只有我已经尝试了几种方法,但不能够
得到我想要的:

I want to apply red background color to 1st li only i have tried several method but not able to get what i want:

#rightmxmenu > ul > li:first-child > {background-color:#ca212d;}
#rightmxmenu > li:first-child > {background-color:#ca212d;}

不会影响任何东西

这里是我的代码和css
http://jsfiddle.net/ gwdp3 / 1 /

here is my code and css http://jsfiddle.net/gwdp3/1/

希望任何专家都能告诉我应该改变什么。

hope any expert can tell me what should i need to change.

推荐答案

更改:

#rightmxmenu > ul > li:first-child > {
    background-color:#ca212d;
}

#rightmxmenu > ul > li:first-child  {
    background-color:#ca212d;
}

jsFiddle示例

jsFiddle example

您不需要尾随>

这篇关于CSS:将背景颜色应用于ul li菜单的第一个孩子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆