如何更改样式表中所有页面上的字体?

时间:2016-01-13 18:02:02

标签: html css fonts

我正在建立一个基本的网站,我已经相当远了,但我偶然发现了一个问题:我希望我的所有标题都是字体“Arvo”,但由于某种原因,只有索引页面在标题中有Arvo。由于我的所有页面都链接到样式表,我应该能够将每个h1更改为该字体。

这是我的样式表的样子,那里可能有一些不必要的代码,但我是一个初学者。

body {
  background: url("https://www.xmple.com/wallpaper/streaks-lines-red-stripes-1920x1080-c4-7f2a33-972c36-b02c39-cb2b3b-l4-45-72-116-187-a-135-f-1.svg") center center repeat;
  margin: 0;
  padding: 0;
  background-attachment: fixed;
}

#wrap {
  width: 54%;
  margin: auto;
  background: #fff2f9;
  overflow: hidden;
  padding: 15px;
}

div {
  width: 300px;
  height: 2000px;
  background-color: white;
  box-shadow: inset 0 100px 100px #ffffff, 0 10px 15px #000;
}

p {
  color: black;
}

h1 {
  font-family: 'Arvo', Georgia, Times, serif; 
  font-size: 59px;
  line-height: 70px;
}

p {
  font-family: 'PT Sans', Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 25px;
}

b {
  font-family: "verdana", sans-serif; color: gold;
  text-shadow: 1px 0 0 #000, 0 -1px 0 #000, 0 1px 0 #000, -1px 0 0 #000;
}

a {
  font-family: "verdana", sans-serif; 
  color: black /* unvisited link */
}

/* visited link */
a:visited {
  color: black;
}

/* mouse over link */
a:hover {
  color: gold;
}

/* selected link */
a:active {
  color: black;
}

}

我需要做什么才能在我的所有HTML页面上更改字体?

1 个答案:

答案 0 :(得分:0)

也许样式是覆盖,因此使用var prevLink = $(this).closest('h2').prevAll('h2').first().find('a').attr('href'); var nextLink = $(this).closest('h2').nextAll('h2').first().find('a').attr('href'); 来修复它。 对所有标题使用以下CSS:

!important

如果您只想将其应用于h1, h2, h3, h4, h5, h6 { font-family: Arvo, Georgia, Times, serif !important; font-size: 59px; line-height: 70px; } ,请删除剩余的标题。在你所说的问题中,所有标题"因此,我添加了所有标题级别。

<强>更新 尝试将字体与您的网页相关联,将以下内容放在h1元素中:

head

导入字体。将以下行放在CSS的开头:

<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Arvo" />