Created
June 17, 2014 01:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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