:第一个孩子选择器或equivelant(:first-child selector or equivelant)
我想设置UL的第一个列表项的样式,列表项包含在<a>标记中。
我本来以为它会很简单,就是这样: http : //jsfiddle.net/PHhFX/但这不起作用。
有人知道吗?
I want to style the first list item of a UL, the list item is encased in an <a> tag.
I would have thought it would be simple, just this: http://jsfiddle.net/PHhFX/ but that isn't working.
Anyone any clue?
最满意答案
您不应该在<a>包含<li> - 在您的HTML中,您只能将<li>元素作为<ul>子元素。
你可能想要反过来做这件事( <li> <a> ),然后选择
ul li:first-childjsFiddle预览
You're not supposed to encase a <li> in an <a> — in your HTML you can only have your <li> elements as children of the <ul>.
You probably meant to do it the other way around (<a> within <li>), then select
ul li:first-childjsFiddle preview
更多推荐
发布评论