Change font size for individual text section in flexdashboard

﹥>﹥吖頭↗ 提交于 2019-12-06 01:35:36

问题


I'm using flexdashboard to create reports and I want to change a font size only for one part of the page.

It feels to me that I can do it by adding CSS class, but I can't find how can I specify class name in R markdown code.

Any ideas?


回答1:


You can add CSS directly into your Rmarkdown document. For example, if you wanted to change the font of objects with class "chart-title" you could insert the following into your R markdown file:

---
title: "Title"
output: 
  flexdashboard::flex_dashboard:
theme: readable
orientation: columns
vertical_layout: fill
---

<style type="text/css">

.chart-title {  /* chart_title  */
   font-size: 30px;
   font-family: Algerian;

</style>



回答2:


Flexdashboard automatically add an id with the same name as the section title to that section. For example if you have a section "my plot", the id for that section will be "my-plot". You can add section-specific css as following

---
title: "Title"
output: 
  flexdashboard::flex_dashboard:
theme: readable
orientation: columns
vertical_layout: fill
---

Row
-----------------------------------------------------------------------
### my plot
plot1

### my plot2
plot2

<style type="text/css">
#my-plot .chart-title{
  font-size: 20px;
}
<style type="text/css">

In the above example, only the font size of the plot 1 will be changed.



来源:https://stackoverflow.com/questions/39764532/change-font-size-for-individual-text-section-in-flexdashboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!