我想在 3 列之间添加一条线:Species Sepal 和 Petal。我怎样才能做到这一点?
sketch = htmltools::withTags(table(
class = 'display',
thead(
tr(
th(rowspan = 2, 'Species'),
th(colspan = 2, 'Sepal'),
th(colspan = 2, 'Petal')
),
tr(
lapply(rep(c('Length', 'Width'), 2), th)
)
)
))
print(sketch)
datatable(iris[1:20, c(5, 1:4)], container = sketch, rownames = FALSE)
Run Code Online (Sandbox Code Playgroud)
你可以做
datatable(iris[1:20, c(5, 1:4)], container = sketch, rownames = FALSE) %>%
formatStyle(c(1,3), `border-right` = "solid 2px")
Run Code Online (Sandbox Code Playgroud)
对于标题中的边框,您可以在sketch以下位置设置 CSS :
sketch = htmltools::withTags(table(
class = 'display',
thead(
tr(
th(rowspan = 2, style = "border-right: solid 2px;", 'Species'),
th(colspan = 2, style = "border-right: solid 2px;", 'Sepal'),
th(colspan = 2, 'Petal')
),
tr(
th("Length"),
th(style = "border-right: solid 2px;", "Width"),
th("Length"),
th("Width")
)
)
))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2811 次 |
| 最近记录: |