CSS 嵌套 :not() 选择器
CSS nested :not() selector
我想将一组 css 规则应用到我的#content div 中的所有(一个)列表,但不允许这些规则影响其他列表中的(两个)列表div.
<!DOCTYPE>
<html>
<head>
<style>
#content *:not(div) ul {list-style:none;}
</style>
</head>
<body>
<div id="content">
<ul>
<li>One</li>
</ul>
<div>
<ul>
<li>Two</li>
</ul>
</div>
</div>
</body>
</html>
您可能需要 "child" or "descendent" selector,它只匹配选择器 >
右侧的那些元素,这些元素是与左侧匹配的元素的直接子元素。如果我理解正确的话,你想要:
#content > ul { list-style: none; }
对于这个特定场景,您可以使用
#content > ul {list-style:none;}
这将针对 #content
元素
的 直接子元素
我想将一组 css 规则应用到我的#content div 中的所有(一个)列表,但不允许这些规则影响其他列表中的(两个)列表div.
<!DOCTYPE>
<html>
<head>
<style>
#content *:not(div) ul {list-style:none;}
</style>
</head>
<body>
<div id="content">
<ul>
<li>One</li>
</ul>
<div>
<ul>
<li>Two</li>
</ul>
</div>
</div>
</body>
</html>
您可能需要 "child" or "descendent" selector,它只匹配选择器 >
右侧的那些元素,这些元素是与左侧匹配的元素的直接子元素。如果我理解正确的话,你想要:
#content > ul { list-style: none; }
对于这个特定场景,您可以使用
#content > ul {list-style:none;}
这将针对 #content
元素