Skip to content

Instantly share code, notes, and snippets.

@Btibert3
Created June 17, 2014 01:14
Show Gist options
  • Save Btibert3/49fa80ec1629090dff7b to your computer and use it in GitHub Desktop.
Save Btibert3/49fa80ec1629090dff7b to your computer and use it in GitHub Desktop.
My StackOverflow question on styling R Markdown tables with knitr::kable and 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;
}
}
---
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"')
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment