我想在我的R Shiny仪表板中为column()
元素设置十进制宽度。例如,我需要5个列,因此我需要每个宽度为2.4。
是否有方法可以实现?
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)
作为替代方案,您可能希望检查 ?splitLayout
,它接受CSS单位: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)