在以下代码段中,我尝试使所有内容具有黑色背景和白色,但 class .toc 除外:< / p>
*:not(.toc) {
color: white;
background: black;
}
<div id="toc" class="toc">
<div id="toctitle">
<h2>z</h2>
</div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="#.D9.81.D9.88.D9.84_.D8.A7.D9.84.D8.B5.D9.88.D9.8A.D8.A7"><span class="tocnumber">1</span> <span class="toctext"><b>a</b></span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#.D9.81.D9.88.D8.A7.D8.A6.D8.AF_.D9.81.D9.88.D9.84_.D8.A7.D9.84.D8.B5.D9.88.D9.8A.D8.A7_.D9.84.D9.84.D9.86.D8.B3.D8.A7.D8.A1"><span class="tocnumber">2</span> <span class="toctext"><b>b</b></span></a></li>
<li class="toclevel-1 tocsection-3"><a href="#.D8.A7.D9.84.D9.82.D9.8A.D9.85.D8.A9_.D8.A7.D9.84.D8.BA.D8.B0.D8.A7.D8.A6.D9.8A.D8.A9_.D9.84.D9.81.D9.88.D9.84_.D8.A7.D9.84.D8.B5.D9.88.D9.8A.D8.A7"><span class="tocnumber">3</span> <span class="toctext"><b>c</b></span></a></li>
<li class="toclevel-1 tocsection-4"><a href="#.D9.85.D8.B6.D8.A7.D8.B1_.D9.81.D9.88.D9.84_.D8.A7.D9.84.D8.B5.D9.88.D9.8A.D8.A7"><span class="tocnumber">4</span> <span class="toctext"><b>d</b></span></a></li>
<li class="toclevel-1 tocsection-5"><a href="#.D9.85.D8.B5.D8.A7.D8.AF.D8.B1_.D9.81.D9.88.D9.84_.D8.A7.D9.84.D8.B5.D9.88.D9.8A.D8.A7_.D8.A7.D9.84.D8.BA.D8.B0.D8.A7.D8.A6.D9.8A.D9.91.D8.A9"><span class="tocnumber">5</span> <span class="toctext"><b>e</b></span></a></li>
<li class="toclevel-1 tocsection-6"><a href="#.D9.85.D8.B1.D8.A7.D8.AC.D8.B9"><span class="tocnumber">6</span> <span class="toctext"><b>b</b></span></a></li>
</ul>
</div>
所以我尝试将选择器替换为:
*:not(.toc) {
color: white;
background: black;
}
但是该类仍然具有样式,我想仅在实际文档文件中取消应用该样式。