您的帖子中没有包含任何屏幕截图,因此很难准确猜测您要解决的问题是什么。
CSS 的基本技术是直接应用于元素的任何样式都会覆盖它们从其祖先继承的任何样式。您不需要“取消设置”从祖先继承的样式,您需要覆盖它们。
.bg-light {
background: white;
color: black;
}
.bg-dark {
background: black;
color: white;
}
<div class="container mt-3">
<h2>Contextual Backgrounds</h2>
<p>Use the contextual background classes to provide "meaning through colors".</p>
<div class="bg-dark">
<h1>Outer</h1>
<p>outer text</p>
<div class="bg-light">
<h1>Inner</h1>
<p>Inner text</p>
</div>
</div>
</div>