如何将内部div中的Bootstrap样式恢复为从body继承的样式?

时间:2014-02-13 20:16:49

标签: css twitter-bootstrap sass

inherited from body具有从bodydiv继承的默认引导样式。

如何在不对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>

fiddle

如果需要,我可以使用SASS,例如通过包含所有默认样式的mixin。

1 个答案:

答案 0 :(得分:0)

  1. 您只需在类initial的CSS中将您更改的内容设置为inner

    .inner {
        color: initial;
    }
    

    小提琴:http://jsfiddle.net/JUMQe/

  2. 您也可以将同一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;
    }
    

    小提琴:http://jsfiddle.net/JUMQe/1/