1

id 下的元素是否有 CSS 选择器?就像上课一样。

我无法更改内部 ul 的类,但我只需要影响“the_id”中的 ul。我可以使用 javascript,但我希望有一个 css 解决方案。

<div id = "the_id">
    <ul>affected<ul>
</div>
<ul>not affected<ul>

CSS:

#the_id ul{list-style:none}
4

1 回答 1

3
/* any descendant */
#the_id ul
   {list-style:none}

/* OR */

/* only children */
#the_id > ul
   {list-style:none;}


<div id="the_id">
    <ul><li>affected</li><ul>
</div>
<ul><li>not affected</li><ul>

另外,使用id="the_id"代替id = "the_id"

于 2013-02-06T09:15:28.873 回答