繁体   English   中英

如何在 R Shiny 中为列设置十进制宽度?

[英]How can I set decimal width for a column in R Shiny?

我想为 R Shiny 仪表板中的column()元素设置十进制宽度。 例如,我需要 5 列,因此我需要每列 2.4 的宽度。

有没有办法做到这一点?

Shiny 的列宽基于Bootstrap 12-wide grid system 您只能指定整数。 但是,您可以嵌套多个列以实现细粒度布局。

以下是有关嵌套列的示例:

library(shiny)

ui <- fluidPage(fluidRow(
  p(),
  column(4, p(), style = "background-color: red;"),
  column(4, p(), style = "background-color: green;"),
  column(
    4,
    column(4, p(), style = "background-color: red;"),
    column(7, p(), style = "background-color: green;"),
    column(1, p(), style = "background-color: blue;")
  ),
))

server <- function(input, output, session) {}

shinyApp(ui, server)

在此处输入图片说明

作为替代方案,您可能需要检查接受 CSS 单位的?splitLayout

library(shiny)

ui <- fluidPage(splitLayout(
  p("red", style = "background-color: red;"),
  p("green", style = "background-color: green;"),
  p("blue", style = "background-color: blue;"),
  p("yellow", style = "background-color: yellow;"),
  p("orange", style = "background-color: orange;"),
  cellWidths = "20%"
))

server <- function(input, output, session) {
}

shinyApp(ui, server)

结果

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM