如何更改 html 中 h2 标签的字体大小
how to change the font size of h2 tag in the html
我正在使用流星 mongo 有一个模板,我正在使用 h2 标签来显示 header。但是我想改变这个 h2 标签的字体大小。我在 CSS 中尝试过,但没有成功。如果我刷新页面,它将采用以前的值。那么谁能建议我如何解决这个问题?
首先定义你的 CSS 并在头文件末尾添加 h2 标签并添加这样的代码
!important;
is override all previous values
you must have to write !important at end of line to override previous value
<style>
h2 {
font-size: 20px !important;
}
</style>
有多种方法可以做到这一点
1.使用内联css
只是做
<h2 style="font-size:40px !important;"></h2>
2。使用内部 css
<style>
h2{
font-size:40px !important;
}
</style>
- 使用外部 css
只需将 class 分配给您的 h2 元素并在外部 css
上为该 class 添加大小
<h2 class="headding"></h2>
然后
.headding{
font-size:40px !important;
}
您可以使用 **40px,40%,40vw,**等尺寸
使用 large 是一种不好的做法,应该尽可能避免。相反,研究使用的选择器的准确性,就像这个小例子:
<div class="my_container">
<div class="other_class">
<h2>
</div>
</div>
And...
.my_container {
.other_class {
h2 {
// your override
}
}
}
所以你必须比旧的选择器更精确才能得到它。
我正在使用流星 mongo 有一个模板,我正在使用 h2 标签来显示 header。但是我想改变这个 h2 标签的字体大小。我在 CSS 中尝试过,但没有成功。如果我刷新页面,它将采用以前的值。那么谁能建议我如何解决这个问题?
首先定义你的 CSS 并在头文件末尾添加 h2 标签并添加这样的代码
!important;
is override all previous values you must have to write !important at end of line to override previous value
<style>
h2 {
font-size: 20px !important;
}
</style>
有多种方法可以做到这一点 1.使用内联css 只是做
<h2 style="font-size:40px !important;"></h2>
2。使用内部 css
<style>
h2{
font-size:40px !important;
}
</style>
- 使用外部 css
只需将 class 分配给您的 h2 元素并在外部 css
上为该 class 添加大小<h2 class="headding"></h2>
然后
.headding{
font-size:40px !important;
}
您可以使用 **40px,40%,40vw,**等尺寸
使用 large 是一种不好的做法,应该尽可能避免。相反,研究使用的选择器的准确性,就像这个小例子:
<div class="my_container">
<div class="other_class">
<h2>
</div>
</div>
And...
.my_container {
.other_class {
h2 {
// your override
}
}
}
所以你必须比旧的选择器更精确才能得到它。