我在html输出Rmarkdown上需要一个水印,但它被数据表掩盖了。
可能有一个简单的答案,但我还不知道Java语言。有提示吗?
我尝试使用 formatStyle ,但无法正常使用:
datatable(mytable, escape = F, class = 'row-border hover compact') %>%
formatStyle(columns = names(mytable), backgroundColor = "#FFFFFF00")
我通过style.css得到水印:
.watermark {
opacity: 0.2;
position: fixed;
top: 50%;
left: 50%;
font-size: 600%;
color: #00407d;
}
以及完整的Rmarkdown示例:
---
title: "Untitled"
output:
html_document:
highlight: pygments
theme: "flatly" # for: html_document black theme: darkly, white them: flatly
toc: TRUE
toc_float: TRUE # for: html_document
css: test-styles.css
---
<div class="watermark">DRAFT</div>
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(DT)
```
## Tables
```{r iris}
DT::datatable(iris, class = '') %>%
DT::formatStyle(columns = "Species", backgroundColor = "#00000000") %>%
DT::formatStyle(columns = "Petal.Width", backgroundColor = "#FFFFFFFFF")
DT::datatable(iris, class = '', options = list(
initComplete = JS("
function(settings, json) {
$(this.api().table().body()).css({
'background-color': 'rgba(255,0,0,0.2)',
'color': 'rgba(0,255,0,0.8)'
});
}")))
```
## Including Plots
You can also embed plots, for example:
```{r pressure, echo=FALSE}
plot(pressure)
```