【问题标题】:how to change the font size of h2 tag in the html如何更改html中h2标签的字体大小
【发布时间】:2020-05-19 01:28:36
【问题描述】:

我正在使用流星和 mongo 有一个模板我正在使用 h2 标签来显示标题。但我想改变这个 h2 标签的字体大小。我在 CSS 中尝试过,但没有成功。如果我刷新页面,它将采用以前的值。那么有人可以建议我如何解决这个问题吗?

【问题讨论】:

    标签: html css mongodb meteor


    【解决方案1】:

    使用 large 是一种不好的做法,应尽可能避免。相反,请注意使用的选择器的准确性,例如这个小示例:

    <div class="my_container">
        <div class="other_class">
            <h2>
         </div>
    </div>
    
    And...
    .my_container {
       .other_class {
          h2 {
            // your override 
          }
       }
    }
    

    所以你必须比旧的选择器更精确才能掌握它。

    【讨论】:

      【解决方案2】:

      有多种方法可以做到这一点 1.使用内联css 做吧

      <h2 style="font-size:40px !important;"></h2>
      

      2。使用内部 CSS

      <style>
      h2{
       font-size:40px !important;
      }
      </style>
      
      1. 使用外部 css

      只需为您的 h2 元素分配一个类并在外部 css 上为该类添加大小

      <h2 class="headding"></h2>
      

      然后

      .headding{
         font-size:40px !important;
      }
      

      您可以使用 **40px、40%、40vw、**等尺寸。

      【讨论】:

        【解决方案3】:

        首先在头文件的末尾用 h2 标签定义你的 CSS 并添加类似的代码

        !important; 覆盖所有以前的值 你必须在行尾写 !important 来覆盖之前的值

        <style>
        h2 {
            font-size: 20px !important;
        }
        </style>
        

        【讨论】:

        • 由于我对这个领域比较陌生,所以我面临一些问题。感谢您花费宝贵的时间,它现在正在运行。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-25
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多