【问题标题】:Set different style for child of class in css [duplicate]在css中为班级的孩子设置不同的样式[重复]
【发布时间】:2020-07-17 20:21:53
【问题描述】:

除了看到两个不同的字体大小,但都具有相同的字体大小

<div class="entry">
<h3>Headquarter 1</h3>
</div>

<div class="h3-block">
<h3>Headquarter 2</h3>
</div>

.h3-block > .h3, h3 {
    font-size: 1.125rem;
}

.entry > .h3, h3 {
    font-size: 1.75rem;
}

【问题讨论】:

    标签: html css font-size


    【解决方案1】:

    如果您输入,h3,则将所有h3标签应用为font-size: 1.75rem;删除它。

    另一个缺失是.h3 意味着您有类为h3 的元素,但您没有需要编写h3 的那种类

    .h3-block > h3{
        font-size: 1.125rem;
    }
    
    .entry > h3 {
        font-size: 1.75rem;
    }
    

    如果你有 h3 的默认字体大小也会放在其他人的顶部

    h3{
       font-size: 1.125rem;// here your default value
    }
    .h3-block > h3{
        font-size: 1.125rem;
    }
    .entry > h3 {
        font-size: 1.75rem;
    }
    

    【讨论】:

      【解决方案2】:

      .h3-block > h3 {
          font-size: 1.125rem;
      }
      
      .entry > h3 {
          font-size: 1.75rem;
      }
      <div class="entry">
      <h3>Headquarter 1</h3>
      </div>
      
      <div class="h3-block">
      <h3>Headquarter 2</h3>
      </div>

      【讨论】:

        猜你喜欢
        • 2018-09-26
        • 1970-01-01
        • 1970-01-01
        • 2015-08-03
        • 2019-08-15
        • 2019-12-26
        • 2018-07-16
        • 1970-01-01
        • 2020-05-08
        相关资源
        最近更新 更多