Bti*_*rt3 25 css r knitr r-markdown
我确信我忽略了一些显而易见的东西,但我想kable用自定义css 制作我的桌子.
你可以在这里找到我RMD和CSS文件的要点 .
我的目标是利用我在这里找到的一些表CSS示例.
当我运行我的报告时,我的表看起来像这样:

但是从上面的CSS示例中,它应该如下图所示.

我的问题:我错过了什么,或者这种风格水平是不可能的RMarkdown.
我的RMD文件也显示如下:
---
title: "Test Table CSS"
output:
html_document:
theme: NULL
style: flat-table.css
---
I want to be able to style my tables with CSS. From the looks of it, I should be able to do that
through the use of `CSS` and `knitr:kable`.
```{r setup, echo=FALSE}
data(mtcars)
mt_head = head(mtcars[, 1:5])
```
I want to be able to style my table just like one found [here](http://codepen.io/njessen/pen/naLCv)
```{r echo=FALSE, results='asis'}
library(knitr)
kable(mt_head, "html", table.attr='class="flat-table"')
```
Run Code Online (Sandbox Code Playgroud)
Tho*_*mas 28
如果您使用下面的.Rmd文件和修改过的CSS文件,您可以通过以下方式获得所需的结果:
knitr::knit2html('my-report.RMD', stylesheet = 'flat-table.css')
Run Code Online (Sandbox Code Playgroud)
这是结果:

这是一个更新的flat-table.css:
.flat-table {
display: block;
font-family: sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 115%;
overflow: auto;
width: auto;
}
th {
background-color: rgb(112, 196, 105);
color: white;
font-weight: normal;
padding: 20px 30px;
text-align: center;
}
td {
background-color: rgb(238, 238, 238);
color: rgb(111, 111, 111);
padding: 20px 30px;
}
Run Code Online (Sandbox Code Playgroud)