2017-10-14 80 views
0

如何以像素爲單位指定sidebarPanel的寬度?對我而言,width的論點不夠準確。如何以像素爲單位指定sidebarPanel的寬度?

library(shiny) 

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

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

shinyApp(ui, server) 

回答

1

您還可以指定width爲百分比,100% =全寬度的函數,而不是硬編碼它px

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) 
0

隨着R shiny - background of sidebar panel的幫助下,我找到了以下解決方案:

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

相關問題