当前位置: 动力学知识库 > 问答 > 编程问答 >

r - How to set padding in header cells of htmlTable package?

问题描述:

I am using htmlTable package in my rmarkdown files. For setting cell padding I use this piece of code:

htmlTable(..., css.cell = "padding-left: .5em; padding-right: .2em;")

How can I do something similar on the header cells?

网友答案:

The key is to add the + 1 rows when specifying the css.cell matrix argument. The default is to only affect the data-cells. Here's an example:

simple_output <- matrix(1:4, ncol=2)
htmlTable(simple_output,
          header = LETTERS[1:2],
          css.cell = rbind(rep("background: lightgrey; font-size: 2em; padding-left: .5em; padding-right: .2em;", times=ncol(simple_output)),
                           matrix("", ncol=ncol(simple_output), nrow=nrow(simple_output))))
分享给朋友:
您可能感兴趣的文章:
随机阅读: