我正在使用xaringan
中来自Yihui的R
库来为演示文稿创建自定义模板。
其中一部分是创建自定义body
幻灯片,如下图所示。
然后我将自定义CSS
用于标题和正文:
.body-yellow > h2 {
font-size: 42px;
text-transform: uppercase;
padding-left:
}
然后只需输入rmarkdown
之类的>
---
class: body-yellow
# Hello
## world
Hello world
然后填充幻灯片。
我的问题是,是否可以为上方模板中显示的图像创建占位符,可以在rmarkdown代码本身中对其进行调整?
我正在想象这样的代码:
---
class: body-yellow
background-images: url(./img/my_new_custom_image.png)
# Hello
## world
Hello world
以及CSS
中的相关调整:
.body-yellow > image {
background-images: PLACEHOLDER
position:right
}
将如下更改图像:
请原谅我的CSS的无知,但我只是涉足这一领域。
答案 0 :(得分:1)
您可以为body-yellow
类设置全局背景图像,并使用特定幻灯片上的background-image
属性覆盖它。这是一个最小的示例:
---
title: "Test"
output:
xaringan::moon_reader:
nature:
ratio: "16:9"
---
class: body-yellow
```{css, echo=FALSE}
.body-yellow > h2 {
font-size: 42px;
text-transform: uppercase;
padding-left: 50px;
}
.body-yellow {
background-image: url(https://i.stack.imgur.com/OSrg8t.png);
background-size: contain;
}
```
## Default background
---
class: body-yellow
background-image: url(https://i.stack.imgur.com/X1C2Bt.png)
## A custom background