如何调整 multiInput() 的高度以占据整个 div



>我在下面的应用程序中使用了shinyWidgets包中的multiInput()

library(shinyWidgets)
library(shiny)
ui <- fluidPage(  
  div(style = "height: 200px;",
  tags$head(
    tags$style(".multi-wrapper {height: 90%;}"), 
    tags$style(".multi-wrapper .non-selected-wrapper, .multi-wrapper .selected-wrapper {height: 100%;}")
  ),
  div(style = "height: 100%; background-color: rgba(0,0,0,.3);",
      multiInput(
        inputId = "id", label = "Fruits :",
        choices = c("Banana", "Blueberry", "Cherry",
                    "Coconut", "Grapefruit", "Kiwi",
                    "Lemon", "Lime", "Mango", "Orange",
                    "Papaya"),
        selected = "Banana", width = "400px",
        options = list(
          enable_search = FALSE,
          non_selected_header = "Choose between:",
          selected_header = "You have selected:"
        )
      )
  )),
  verbatimTextOutput(outputId = "res")
)
server <- function(input, output, session) {
  output$res <- renderPrint({
    input$id
  })
}
shinyApp(ui = ui, server = server)

我希望multiInput()应该占据父Div的整个高度,而这里的情况并非如此。任何如何实现这一目标的想法都会有所帮助

似乎有效:

library(shinyWidgets)
library(shiny)
ui <- fluidPage(  
  tags$head(
    tags$style(".multi-wrapper {height: 350px;}"), # 350 = 400-50 (400 is the height of the div)
    tags$style(".multi-wrapper .non-selected-wrapper, .multi-wrapper .selected-wrapper {height: 100%;}")
  ),
  div(style = "height: 400px",
      multiInput(
        inputId = "id", label = "Fruits :",
        choices = c("Banana", "Blueberry", "Cherry",
                    "Coconut", "Grapefruit", "Kiwi",
                    "Lemon", "Lime", "Mango", "Orange",
                    "Papaya"),
        selected = "Banana", width = "400px",
        options = list(
          enable_search = FALSE,
          non_selected_header = "Choose between:",
          selected_header = "You have selected:"
        )
      )
  ),
  verbatimTextOutput(outputId = "res")
)
server <- function(input, output, session) {
  output$res <- renderPrint({
    input$id
  })
}
shinyApp(ui = ui, server = server)

最新更新