[英]CSS, Styling the Parent/Root but not the children? W/O creating sloppy CSS
So this is new, I'm trying to create clean CSS, here's my code example: 所以这是新的,我正在尝试创建干净的CSS,这是我的代码示例:
<ul id="Main">
<li>blah blah</li>
<li>blah blah</li>
<li>blah blah</li>
<li>
<ul>
<li>ding dong</li>
<li>ding dong</li>
<li>ding dong</li>
</ul>
</li>
</ul>
Then I have the following CSS: 然后我有以下CSS:
#Main li {
background-color:Red;
}
Problem is I don't want the background-red in the DING DONG LI's is there a way in CSS to say not the root / children? 问题是我不希望DING DONG LI的背景红色在CSS中有一种方法可以说不是根/子级吗? Or do I need another ID/CLASS to cancel out the parent styling?
还是我需要另一个ID / CLASS才能取消父样式?
Thanks 谢谢
. 。
#Main > li {
background-color:Red;
}
a > b
means that b
is direct child of a
a > b
指b
是直接子a
#Main li { background:red; }
#Main li li { background:transparent; }
One could use >
but it doesn't work in IE6. 一个可以使用
>
但是在IE6中不起作用。 One could add additional *
styles for IE6 but the above is arguably more succinct. 可以为IE6添加其他
*
样式,但是上面的说法可能更简洁。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.