inherited from body
具有从body
和div
继承的默认引导样式。
如何在不对Bootstrap使用的值进行硬编码的情况下使内部类具有与inherited from body
完全相同的样式:
<div>inherited from body</div>
<div style="font-size:30px;">
custom
<div class="inner">BAD! I want this to have the same style as "inherited from body"</div>
<div class="inner" style="font-size:16px;">BAD! Same style as "inherited from body", but I don't want to hardcode the value.</div>
</div>
如果需要,我可以使用SASS,例如通过包含所有默认样式的mixin。
答案 0 :(得分:0)
您只需在类initial
的CSS中将您更改的内容设置为inner
:
.inner {
color: initial;
}
您也可以将同一id
应用于<div>
:
<强> HTML 强>:
<div id="same">default</div>
<div style="color:green; background-color:green;">
green
<div class="inner" id="same">inner default</div>
</div>
<强> CSS 强>:
#same {
color: #F00;
}