繁体   English   中英

如何以像素为单位指定sidebarPanel的宽度?

[英]How to specify the width of a sidebarPanel in pixels?

如何以像素为单位指定sidebarPanel的宽度? 在我的情况下, width参数不够准确。

library(shiny)

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(width = 5), # This is not accurate enough!
    mainPanel()))

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

shinyApp(ui, server)

您还可以将width指定为百分比的函数,而不是将其硬编码为px而是100% =全角

library(shiny)

ui <- fluidPage(
  sidebarLayout(
    div(style="width: 70%;",sidebarPanel(width = 5)), # This is not accurate enough!
    mainPanel()))

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

shinyApp(ui, server)

借助R Shiny-侧边栏面板的背景,我找到了以下解决方案:

library(shiny)

ui <- fluidPage(
  tags$head(tags$style(HTML('#sidebar {width: 100px;}'))),
  sidebarLayout(
    sidebarPanel(id = "sidebar"),
    mainPanel()))

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

shinyApp(ui, server)

这不会影响其他wellPanels

暂无
暂无

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

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