0

我正在尝试排列页脚菜单并仅选择第一个列表元素作为单个选择

<ul class="someclass">
    <li><!--this is what I am trying to capture-->

        <a>something arbitrary here</a>
        <ul>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
        </ul>
    </li>
    <li>
        <a>something arbitrary here</a>
        <ul>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
        </ul>
    </li>
    <li>
        <a>something arbitrary here</a>
        <ul>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
            <li>list elemnts here</li>
        </ul>
    </li>
</ul>

我希望能够选择所有顶部<li>元素,而无需直接选择所有其他内部<li>元素。我应该使用哪些 CSS 选择器?

4

1 回答 1

1
.someclass > li:first-child {
}

示例:http: //jsfiddle.net/yUMwD/

或者选择li该级别的所有 s:

.someclass > li {
}

>意思是“子元素”,所以它会li直接在下面.comeclass

于 2013-03-02T12:25:28.827 回答