我学会了通过执行 <p style="font-family:;></p>
来更改正文中文本的字体系列,但是我将如何为标题做呢?另外,有没有办法为整个文档修复字体系列?
如何更改 html 中标题的字体系列?
答案:
您可以在 HTML 文件的 head 元素中编写样式元素,以在整个文档中全局应用样式:
<style>
title {
font-family:; /* usually the name of your font goes here */
}
</style>
您想在 style.css 中使用 (html{}) 因此,它将适用于 (HTML) 中的任何元素。除非您另有明确说明。
在这个问题上,在这个例子中,我给了你如果你要删除 child1 或 child2 font-family 如果你要从 body 中删除 font-family 它将默认为 body 部分中的任何内容,它将默认为的 HTML。
[
/*Change the font style on the Entire Document */
html{
font-family: "Montserrat", sans-serif;
font-size: 1rem;
color: Gray;
}
/*Change on the Body*/
body{
font-family: "Montserrat", sans-serif;
font-size: 2rem;
color: white;
background-color: #333;
text-align:center;
}
/*Change on a specific elements*/
#container .child1{
font-family: cursive;
font-size: 2rem;
color: white;
text-align:center;
background-color: blue;
}
#container .child2{
font-family: cursive;
font-size: 2rem;
color: white;
background-color: green;
text-align:center;
}
footer{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
<header>
<p>I am the Header</p>
</header>
<div id="container">
<div class="child1">
<p>I am a Body Child</p>
</div>
<div class="child2">
<p>I am another body Child</p>
</div>
</div>
<footer> I am the Footer</footer>
]1
如果您真的想设置整个文档,您可以使用下面的说明,除非您指定 !important ,否则更具体的选择器将覆盖它(尽管我强烈建议不要在如此庞大的选择器上使用 !important ):