我正在创建四开幻灯片并使用两列布局来比较代码段。但是,我想在列之间添加一些空格,特别是对于较长的代码行。作为解决方法,我在中间添加了第三列,但我更喜欢更优雅的 css 解决方案
---
title: "Test"
format: revealjs
---
## Two columns without space
::: {.column width="49%"}
```{r, echo=TRUE}
x <- runif(100)
plot(x)
```
:::
::: {.column width="49%"}
```{r, echo=TRUE}
x <- rnorm(100)
plot(x)
```
:::
## Two columns with space
::: {.column width="44%"}
```{r, echo=TRUE}
x <- runif(100)
plot(x)
```
:::
::: {.column width="10%"}
:::
::: {.column width="44%"}
```{r, echo=TRUE}
x <- rnorm(100)
plot(x)
```
:::
您可以使用额外的 css 类添加空间(技巧是创建列,使两者都不会覆盖 100%):
---
title: "Test"
format: revealjs
---
<style>
.add-space{
padding-right: 11%;
}
</style>
## Two columns without space
::: {.column width="44%" .add-space}
```{r, echo=TRUE}
x <- runif(100)
plot(x)
```
:::
::: {.column width="44%"}
```{r, echo=TRUE}
x <- rnorm(100)
plot(x)
```
:::