4

我使用来自 shinyWidget 的 pickerInput

div(class = "choosechannel",
pickerInput(inputId = "choosechannel", label = "business channel", width = "150px",
choices = c("In-Branch", "Agency", "Affinity", "Corporate", "Credit Life"),
multiple = TRUE, selected = c("In-Branch", "Agency", "Affinity", "Corporate", "Credit Life"),
options = list(height = 10)))

我想更改 pickerInput 的高度这是我尝试使用的代码:

tags$style(".choosechannel-button {height: 26.5px; min-height: 26.5px; padding: 0px;}")

tags$head( tags$style( HTML("#choosechannel-button {font-size: 13px; height: 26.5px; min-height: 26.5px;}")))

tags$style(".choosechannel-container {height: 26.5px; min-height: 26.5px; padding: 0px;}")

tags$head( tags$style( HTML("#choosechannel-container {font-size: 13px; height: 26.5px; min-height: 26.5px;}")))

它们都不起作用。有谁知道该怎么做?

.choosechannel .btn {height: 26.5px; font-size: 13px;}编辑:正如 Wilmar van Ommeren 在他的回答中所建议的那样,我在 tags$style 中尝试过。它几乎可以工作。它下面仍然有空白区域。
它看起来像这样:
这里

4

1 回答 1

3

你快到了。您想要的是更改.btn班级中的.choosechannel班级。您可以使用点 ( ) 指向由另一个类继承的类.choosechannel .btn {...}

工作示例:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  tags$style(".choosechannel .btn {height: 26.5px; min-height: 26.5px; padding: 0px;}"),
  div(class = "choosechannel",
      pickerInput(inputId = "choosechannel", label = "business channel", width = "150px",
                  choices = c("In-Branch", "Agency", "Affinity", "Corporate", "Credit Life"),
                  multiple = TRUE, selected = c("In-Branch", "Agency", "Affinity", "Corporate", "Credit Life"),
                  options = list(height = 10))) 
)

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

}

shinyApp(ui, server)
于 2019-12-09T14:00:58.487 回答