如何删除 tint::tintHtml 在 kable table 中的单元格周围添加的白色 padding/borders?

How to remove white padding/borders that tint::tintHtml added around cells in kable table?

我想去掉每个单元格周围的白色。当我编织到 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") 

```

第一步:您可以“右键单击网页上的元素,然后 select Inspect Element

第二步:您需要覆盖默认值 border-spacing (Bootstrap CSS) 属性:

The border-spacing property sets the distance between the borders of adjacent cells.
Note: This property works only when border-collapse is separate.

<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") 
```