Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css Rmarkdown html报告中的DT datatable透明背景_Css_R_R Markdown_Dt - Fatal编程技术网

Css Rmarkdown html报告中的DT datatable透明背景

Css Rmarkdown html报告中的DT datatable透明背景,css,r,r-markdown,dt,Css,R,R Markdown,Dt,我需要在html输出Rmarkdown上添加水印,但它被数据表屏蔽了 可能有一个简单的答案,但我还不知道Javascript。有小费吗 我尝试过使用formatStyle,但效果不理想: datatable(mytable, escape = F, class = 'row-border hover compact') %>% formatStyle(columns = names(mytable), backgroundColor = "#FFFFFF00") 我使用style.

我需要在html输出Rmarkdown上添加水印,但它被数据表屏蔽了

可能有一个简单的答案,但我还不知道Javascript。有小费吗

我尝试过使用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)
```
---
标题:“无标题”
输出:
html_文件:
推荐理由:pygments
主题:“flatly”#用于:html#文档黑色主题:黑色,白色主题:flatly
toc:没错
toc_float:TRUE#for:html_文档
css:test-styles.css
---
草稿
```{r设置,include=FALSE}
knitr::opts_chunk$set(echo=TRUE)
图书馆(DT)
```
##桌子
```{r iris}
DT::数据表(iris,类=“”)%>%
DT::formatStyle(columns=“Species”,backgroundColor=“#00000000”)%>%
DT::formatStyle(columns=“Petal.Width”,backgroundColor=“#FFFFFFFFF”)
DT::datatable(iris,类=“”,选项=列表(
initComplete=JS(“
函数(设置,json){
$(this.api().table().body()).css({
“背景色”:“rgba(255,0,0,0.2)”,
“颜色”:“rgba(0255,0,0.8)”
});
}")))
```
##包括情节
还可以嵌入打印,例如:
```{r压力,回波=假}
绘图(压力)
```

水印
类中添加一个大的
z索引

.watermark {
  opacity: 0.2;
  position: fixed;
  top: 50%;
  left: 50%;
  font-size: 600%;
  color: #00407d;
  z-index: 1000000;
}
然后只需执行
datatable(iris)
,无需设置背景色