闪亮的选择下拉菜单向上打开

Wil*_*ren 9 html css r shiny twitter-bootstrap-3

在我闪亮的仪表板中,我有几个selectizeInput类型的下拉菜单。它们位于页面底部,因此我不想向下打开下拉菜单,而是向上打开它们。

我确实找到了名为pickerInput 的下拉菜单的解决方案。这里的解决方案是添加一个标签:shinyWidgetscss

.dropdown-menu{bottom: 100%; top: auto;}
Run Code Online (Sandbox Code Playgroud)

但是,此标记不适用于selectizeInput. 知道css我必须添加到我的脚本中吗?

编辑(maartenzam 举例回答)

library(shiny)

ui <- fluidPage(
  # selectize style
  tags$head(tags$style(type = "text/css", paste0(".selectize-dropdown {
                                                     bottom: 100% !important;
                                                     top:auto!important;
                                                 }}"))),
  div(style='height:200px'),
  selectizeInput('id', 'test', 1:10, selected = NULL, multiple = FALSE,
                 options = NULL)
)

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

}

shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)

小智 6

你可以做一些像

.selectize-dropdown {
  top: -200px !important;
}
Run Code Online (Sandbox Code Playgroud)


ism*_*gal 6

谢谢这个,非常有用!

将其留在这里以防万一有人有兴趣仅更改某些 的行为selectizeInput并保留其他默认值(就像我一样):

library(shiny)

ui <- fluidPage(
  tags$head(tags$style(HTML('#upwardId+ div>.selectize-dropdown{bottom: 100% !important; top:auto!important;}'))),
  selectizeInput(inputId = 'downwardId', label='open downward', choices = 1:10, selected = NULL, multiple = FALSE),
  div(HTML("<br><br><br><br><br>")),
  selectizeInput(inputId = 'upwardId', label='open upward', choices = 1:10, selected = NULL, multiple = FALSE)
)

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

shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)