如何使用css将字体类型应用于所有内容

Ref*_*ing 5 css

基本上,我需要在未指定的任何地方调整字体类型.我怎样才能做到这一点?table,div,span,p,input,你的名字.有没有办法可以用1 css规则来完成它们我可以添加?

Mar*_*rko 7

的,在 body 元素上使用它,除非您另行指定,否则它将级联到所有子元素。

body {
    font-family: Arial, Verdana, sans-serif;
}
#tahoma {
    font-family: Tahoma, sans-serif;
}
Run Code Online (Sandbox Code Playgroud)

然后你可以覆盖它

<body>
  <div id="default">
    I will inherit the body font-family, in this case Arial because no other rule has been set!
  </div> 
  <div id="tahoma">
    <p>Me, <span>Me</span> and <strong>Me</strong> are using Tahoma because our parent #tahoma says so.</p>
  </div>
</body>
Run Code Online (Sandbox Code Playgroud)

  • 该死的你打败了我 5 秒;) (2认同)