html - 在 html 文档中使用多种 Google 字体
问题描述
我想将 google 字体仅应用于我页面中的特定 css 选择器或元素。
我也想要在多重权重中使用相同的字体(例如 Roboto)。不使用 css 属性进行控制,但实际上使用 google 提供的单独字体版本。
如果可能,id 不希望有外部样式表。
这可能吗?如果必须,我不介意在脚本标签中做。
解决方案
在这里你有一个例子,我已经把样式放在了 html 中,所以你不需要外部样式表,尽管我不推荐它
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Rowdies&display=swap" rel="stylesheet">
<style>
h2,
h3,
span {
font-family: 'Roboto', sans-serif;
}
h2 {
font-weight: 500;
}
h3 {
font-weight: 700;
}
h1,
p {
font-family: 'Rowdies', cursive;
}
</style>
<h1>h1 Rowdies</h1>
<h2>h2 Roboto font-weight 500</h2>
<h3>h3 Roboto font-weight 700</h3>
<p>p Rowdies</p>
<span>span Roboto</span>
我也想要在多重权重中使用相同的字体(例如 Roboto)。不使用 css 属性进行控制,但实际上使用 google 提供的单独字体版本。
不是 100% 确定它是否可能,但我认为你没有理由不能只使用该font-weight
物业
推荐阅读
- vba - 输入框中的标准函数并显示结果
- php - 在 WP_Query 中按 menu_order 对特定的 Woocommerce 产品变体进行排序
- python - 找不到 pyinstaller 添加数据文件
- database - 表中的每一行都有不同的元数据列
- azure-active-directory - 从 Azure Active Directory Graph Api 迁移到 Microsoft Graph Api
- visual-studio - 如何创建使用 LLVM 的 Visual Studio 项目
- html - 带有固定标题的表格 - tbody 在我的表格中溢出
- nand2tetris - nand2tetris CPU.cmp 第 17 行问题;outM/(RAM[A]) 使用 MD=D-1 指令递减两次;
- regex - 正则表达式匹配来自多个链接的文本
- kubernetes - 在 Kubernetes 中重新部署不会缩减旧的 Replica 集