【问题标题】:Shiny table loses centering when placed in iframe放置在 iframe 中时,闪亮的表格会失去居中
【发布时间】:2021-01-20 01:10:49
【问题描述】:

这是一个大致位于页面中心的 Shiny 表格。可以看到here

library(shiny)
library(reactable)

df <- mtcars[1:4, 1:3]

ui <- fluidPage(
  h4("Here is a heading"),
  fluidRow(
    column(3, align="center"),
    reactableOutput("table"))
)

server <- function(input, output, session) {
  output$table <- renderReactable({
    reactable(df,
              fullWidth = FALSE)
  })
}

shinyApp(ui, server)

如果我从 iframe 链接到这个 Shiny 应用程序,中心会消失,如 here 所示。

<!DOCTYPE html>
<html>
<body>

<div >
<iframe src="https://whatbank.ca/tmp" width=500; height=1000; style="margin-bottom: 1px;" frameborder="0" >
</iframe>
</div>

</body>
</html>
  1. 如何在 iframe 中保持居中?
  2. 这是column(3, align="center"), 使表格居中的正确方法吗?

【问题讨论】:

  • 为了使表格居中,我会这样做fluidRow(column(12, align="center", reactableOutput("table")))
  • 是的,在我给出的示例中有效。不幸的是,你无法读懂我的想法并意识到我想要的是一个 tabBox 的解决方案,它位于 ui = dashboardPage(...

标签: css r iframe shiny


【解决方案1】:

那是因为width=500 太小了。试试width="100%"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-14
    • 1970-01-01
    • 2014-01-01
    • 2020-09-24
    • 2018-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多