r-markdown - 如何删除 tint::tintHtml 在 kable 表中的单元格周围添加的白色填充/边框?
问题描述
我想摆脱每个细胞周围的白色。当我编织到 html_document 时,没有这样的填充。
我猜 tint.css 文件对此负责(https://github.com/eddelbuettel/tint/blob/master/inst/rmarkdown/templates/tintHtml/resources/tint.css)
---
title: tintHtml() add padding to kable "
output: tint::tintHtml
---
```{r}
library(kableExtra)
library(magrittr)
```
```{r}
knitr::kable(
mtcars[1:6, 1:6],
caption = 'how do I get rid of white padding ?'
) %>%
row_spec(0, background = "blue", color = "white") %>%
row_spec(1, background = "green", color = "white")
```
解决方案
第一步:您可以“右键单击网页上的元素并选择检查元素”
第二步:您需要覆盖默认的边框间距(Bootstrap CSS)属性:
border-spacing属性设置相邻单元格边界之间的距离。
注意:此属性仅在border-collapse为 独立时有效。
<style>
table{
border-spacing: unset; # values: inherent, initial, unset or 0px
}
</style>
输出:
---
title: tintHtml() add padding to kable "
output: tint::tintHtml
---
```{r}
library(kableExtra)
library(magrittr)
```
<style>
table{
border-spacing: unset; # inherent, initial, unset, 0px
}
</style>
```{r}
knitr::kable(
mtcars[1:6, 1:6],
caption = 'how do I get rid of white padding ?'
) %>%
row_spec(0, background = "blue", color = "white") %>%
row_spec(1, background = "green", color = "white")
```
推荐阅读
- postgresql - 针对某个简单查询进行优化
- javascript - 在canvasjs中为甜甜圈图制作标签索引多行
- javascript - Laravel vue js mixins没有得到函数响应
- laravel - 如何根据要求按条件在 laravel eloquent 中添加或删除属性
- c# - 无法导入 RSA 私钥:“提供程序的错误版本”
- ios - 如何在 textField 上方实现/显示以下弹出窗口?
- apache-atlas - 无法删除 Apache Atlas 分类
- sql - 给定递增的 ID 值和创建日期,创建 SQL 语句以查找是否有任何日期与 oracle 中的 ID 不一致
- android - 处理带有多个片段和活动的 backStack
- asp.net-mvc - 如何在视频中寻找asp mvc?