html - 使用 knitr 导入 html 输出的字体类型

标签 html css rstudio r-markdown knitr

我正在尝试导入以下字体以在我的 html 输出中使用。它们已包含在我的 .css 文件中,但它不起作用。

@import url('https://fonts.googleapis.com/css?family=Josefin+Sans:300,300i,400,400i,600,600i,700,700i');
@import url('https://fonts.googleapis.com/css?family=Fira+Sans:300,300i,400,400i,500,500i,600,600i,700,700i');
@import url('https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600');

h1, h2, h3 {
  font-family: 'Josefin Sans, serif';
  font-weight: normal;
}

body {
  font-family: 'Fira Sans', serif;
}

.remark-code, .remark-inline-code { 
  font-family: 'Source Code Pro', monospace;
}

我的 YAML 看起来像这样:

---
title: "title"
subtitle: "subtitle"
author:  "author"
date: "date"
output:
  html_document:
    toc: true # table of content true
    toc_float: true
    depth: 3  # upto three depths of headings (specified by #, ## and ###)
    number_sections: false  ## if you want number sections at each table header
    css: [style.css]
    highlight: zenburn  # specifies the syntax highlighting style
    fig.retina: 3
    self_contained: yes
---

为什么我的 html 输出没有使用指定的字体?我们非常欢迎任何帮助!

最佳答案

在您的代码中进行以下更改

h1, h2, h3 {
  font-family: 'Josefin Sans', serif;
  font-weight: normal;
}

Right Way ->  font-family: 'Josefin Sans', serif;
Wrong Way ->  font-family: 'Josefin Sans, serif';

关于html - 使用 knitr 导入 html 输出的字体类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58779282/

相关文章:

r - R 中 scan() 的替代方案(此处文档样式)

R- 在 Rmarkdown 中绘图时文件名无效错误

html - 有没有办法让Vue组件的模板仅包含属性文本?

html - 如何验证文本区域中的模式匹配?

r - 如何将 'learnr' 中的教程问题嵌入到完整的 Shiny 应用程序中?

css - 页脚无法在移动浏览器上正确显示

html - 用响应式 <image> 填充一个 div 并居中放置

html - 伪元素上的 Font Awesome 5 显示正方形而不是图标

javascript - 带有 HTML5 的 asp.net 的验证组功能

php - 使用 CSS 和 PHP 实现多语言