在夸托v1.3中,是否有方法覆盖表的 Bootstrap 样式?

tquggr8v  于 2023-04-09  发布在  Bootstrap
关注(0)|答案(1)|浏览(99)

我使用夸托创建了一个包含大量表格的网站。因为我希望表格具有特定的外观,所以我使用huxtable添加边框。以下面为例:

```{r}
t1 = matrix(c("",         "menu",   "",      "",     "", 
              "",         "",       "yes",   "no",   "", 
              "group",    1,        1,        4,      5,
              "",         2,        5,        1,      6,
              "",         "",       6,        5,      11),
            nrow = 5, byrow = T)

huxtable::as_hux(t1) |> 
  set_bottom_border(row = c(2,4), col = 2:5) |>
  set_bottom_border(row = c(1,5), col = c(3,4)) |>
  set_right_border(row = 2:5, col = c(2,4)) |> 
  set_right_border(row = c(3,4), col = c(1,5)) |> 
  
  merge_cells(row = 1, col = 2:5) |> 
  merge_cells(row = c(3,4), col = 1) |> 
  set_align(row = everywhere, col = everywhere, "center")

这曾经用来创建漂亮的表格。但是自从我升级到夸托版本1.3后,在渲染时,它似乎用bootstrap-design覆盖了我的布局输入。现在看起来很荒谬:[See here](https://i.stack.imgur.com/Bwj09.png)
有没有什么方法可以抑制bootstrap-layouting?
我尝试使用`set_background_color()`将背景设置为白色,但没有用。我可以使用`print_html()`,复制输出并将其粘贴在代码块之后,但这很快真实的混乱,因为我必须对这些表进行大量更改。我看到的另一种解决方案是在. css文件中指定表布局,但这也不是很好,因为我有很多不同大小的表,因此为所有的单独的指定布局将是非常乏味的。
任何帮助将不胜感激。
c6ubokkw

c6ubokkw1#

尝试print_html沿着chunk选项output: asis

---
title: Table style
format: html
---

```{r}
#| output: asis

library(huxtable)

t1 = matrix(c("",         "menu",   "",      "",     "", 
              "",         "",       "yes",   "no",   "", 
              "group",    1,        1,        4,      5,
              "",         2,        5,        1,      6,
              "",         "",       6,        5,      11),
            nrow = 5, byrow = T)

huxtable::as_hux(t1) |> 
  set_bottom_border(row = c(2,4), col = 2:5) |>
  set_bottom_border(row = c(1,5), col = c(3,4)) |>
  set_right_border(row = 2:5, col = c(2,4)) |> 
  set_right_border(row = c(3,4), col = c(1,5)) |> 
  merge_cells(row = 1, col = 2:5) |> 
  merge_cells(row = c(3,4), col = 1) |> 
  set_align(row = everywhere, col = everywhere, "center") |> print_html()

![](https://i.stack.imgur.com/Gq4LO.png)

相关问题