CSS选择器:具有id的元素的子元素

时间:2013-02-06 09:08:49

标签: css

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

我不可能改变内部ul的类,但我只需要内部的ul" the_id"受到影响我可以使用javascript,但我希望有一个css解决方案。

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

的CSS:

#the_id ul{list-style:none}

1 个答案:

答案 0 :(得分: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"