以下ui
示例的 包含四个selectInput
. 最后两个在一个splitLayout
. 我注意到,当我启动应用程序时,如果窗口大小不够大,最后两个标签会重叠,如第一个屏幕截图所示。是否可以使输入的标签splitLayout
动态变化取决于窗口的宽度?比较将是前两个selectInput
。如第二个屏幕截图所示,当我减小窗口宽度时,标签会变为两行。我希望 .in 中的最后两个具有相同的selectInput
行为splitLayout
。
library(shiny)
# Define UI
ui <- fluidPage(
mainPanel(
selectInput(inputId = "A", label = "This is a long lebel with lots of words", choices = letters[1:5], selected = "a"),
selectInput(inputId = "B", label = "This is a long lebel with lots of words", choices = letters[1:5], selected = "a"),
splitLayout(
selectInput(inputId = "C", label = "This is a long lebel with lots of words", choices = letters[1:5], selected = "a"),
selectInput(inputId = "D", label = "This is a long lebel with lots of words", choices = letters[1:5], selected = "a"),
# Expand the menu in splitLayout
# From: https://stackoverflow.com/a/40098855/7669809
tags$head(tags$style(HTML("
.shiny-split-layout > div {
overflow: visible;
}
")))
)
)
)
# Server logic
server <- function(input, output, session){
}
# Complete app with UI and server components
shinyApp(ui, server)
第一张截图:
第二张截图:
更新
@Simran 指出这overflow: visible
是导致此问题的原因。但是,我需要这个来selectInput
根据这篇文章扩展我的菜单:https ://stackoverflow.com/a/40098855/7669809