无法使字体粗细工作 我该如何使它工作?
Can't make font-weight work how do i make it work?
我无法获取用于加载不同字重的字体。
我试过从 google 字体中加载所有不同的字重,并尝试在我的 css 和
在我的css中:
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800');
* {
font-family: 'Open Sans', sans-serif;
}
.titles{
align-content:left;
font-weight:800;
}
在我的html中:
<div class="titles">
<h2> What we do.</h2>
</div>
在你的 html 的 head 标签中使用 link :)
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800&display=swap" rel="stylesheet">
小心,不要将 import
link 分成多行,并检查 link 中的空格。它应该都在一条线上。没有空格或分界线。
@import
如果您有不同的样式表并且您只需要在特定样式表中导入,则应使用。或者,如果您无权编辑 <head>
元素。
否则,您应该使用 html <link>
元素将您的字体直接包含在 head
元素中。
检查下面
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800');
* {
font-family: 'Open Sans', sans-serif;
}
.titles {
align-content: left;
font-weight: 800;
}
<div class="titles">
<h2> What we do.</h2>
</div>
您的 800 值已被 h2
元素的默认浏览器设置 700 否决,因为您仅将其应用于 .titles
。您需要将 font-weight: 800
专门应用于 h2
元素。
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800');
* {
font-family: 'Open Sans', sans-serif;
}
.titles h2 {
align-content: left;
font-weight: 800;
}
<div class="titles">
<h2>What we do.</h2>
</div>
我无法获取用于加载不同字重的字体。
我试过从 google 字体中加载所有不同的字重,并尝试在我的 css 和
在我的css中:
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800');
* {
font-family: 'Open Sans', sans-serif;
}
.titles{
align-content:left;
font-weight:800;
}
在我的html中:
<div class="titles">
<h2> What we do.</h2>
</div>
在你的 html 的 head 标签中使用 link :)
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800&display=swap" rel="stylesheet">
小心,不要将 import
link 分成多行,并检查 link 中的空格。它应该都在一条线上。没有空格或分界线。
@import
如果您有不同的样式表并且您只需要在特定样式表中导入,则应使用。或者,如果您无权编辑 <head>
元素。
否则,您应该使用 html <link>
元素将您的字体直接包含在 head
元素中。
检查下面
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800');
* {
font-family: 'Open Sans', sans-serif;
}
.titles {
align-content: left;
font-weight: 800;
}
<div class="titles">
<h2> What we do.</h2>
</div>
您的 800 值已被 h2
元素的默认浏览器设置 700 否决,因为您仅将其应用于 .titles
。您需要将 font-weight: 800
专门应用于 h2
元素。
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800');
* {
font-family: 'Open Sans', sans-serif;
}
.titles h2 {
align-content: left;
font-weight: 800;
}
<div class="titles">
<h2>What we do.</h2>
</div>