【问题标题】:How to change the height of select dropdown in shiny?如何更改闪亮的选择下拉菜单的高度?
【发布时间】:2015-02-09 17:27:33
【问题描述】:

我想更改闪亮应用中选择下拉菜单的高度。默认高度显示大约8个选项,我想看更多。可以通过降低下拉菜单的行高来增加选项的数量,但这对我来说不是最佳解决方案。我搜索了很多关于如何做到这一点,查看了 selectize.js 代码,我目前的假设是这要么是微不足道的,要么是设计上不可能的。

我了解到,从 select 中显示的下拉列表是 .selectize-dropdown-content 类的 div,但更改其高度和宽度属性不会改变任何内容。虽然可以更改背景颜色。这是我的单文件闪亮应用代码:

server <- function(input, output) {
    output$distPlot <- renderPlot({
        plot(0.5,0.5,xlim=c(0,1),ylim=c(0,1))
        text(0.5,0.5,input$Letter)
  })
}

ui <- shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel(
        selectizeInput("Letter", "", setNames(letters,letters),selected="a",multiple=FALSE),       
        tags$style(type='text/css',
                   ".selectize-dropdown-content {
height: 600 px;
width: 700 px;
background-color: #b0c4de;
}")
    ),
    mainPanel(plotOutput("distPlot"))
  )
))

shinyApp(ui = ui, server = server)

所以我的问题是,我是在修改正确元素的 css,还是在 selectize.js 中无法更改下拉高度?

【问题讨论】:

    标签: r shiny selectize.js


    【解决方案1】:

    在发布问题几分钟后得到解决方案。选择下拉菜单的高度由max-height 属性控制。以下 css 可以解决问题:

    tags$style(type='text/css', ".selectize-dropdown-content {max-height: 400px; }"), 
    

    【讨论】:

    • 很抱歉意外投反对票。看起来我无法还原它。
    • 别担心 :) 让这条评论更长
    猜你喜欢
    • 2021-05-01
    • 1970-01-01
    • 2014-10-05
    • 2014-10-18
    • 1970-01-01
    • 2021-03-21
    • 1970-01-01
    • 1970-01-01
    • 2021-10-03
    相关资源
    最近更新 更多