【问题标题】:Shiny - change the size (padding?) of dropdown menu (select tags) smallerShiny - 将下拉菜单(选择标签)的大小(填充?)变小
【发布时间】:2015-08-12 10:18:46
【问题描述】:

如何将下拉菜单(选择标签)的尺寸变小?我认为是填充使下拉菜单看起来“厚”。所以我将填充更改为 0 以使其“变薄”,显然这不起作用,

shinyUI(fluidPage(

  sidebarPanel(

    # Change the font size.
    tags$style(type='text/css', " .selectize-input, .selectize-dropdown { padding:0 ; }"),

    # Species/ pollutant options
    selectInput(
        inputId = "species",
        label = "Species:",
        choices = c(...)
        ),
   ....

结果很尴尬,

有什么想法吗?

【问题讨论】:

  • 没有跨浏览器的解决方案来设置大多数表单元素的样式,其中 <select><input type="radio" /><input type="checkbox" /> 仅使用 CSS。

标签: html css r shiny


【解决方案1】:

对于下拉选项,您想要的是line-height(我认为默认情况下填充已为 0,请使用 chrome 调试器查看其上的 CSS)。

对于盒子本身,bootstrap 似乎在其上放置了min-height,因此您还需要添加min-height: 0;。同样,我现在只是通过查看它的 CSS 使用调试器解决了这个问题。

所以这是一个可行的解决方案:

runApp(shinyApp(
  ui = fluidPage(
    tags$style(type='text/css', ".selectize-input { padding: 2px; min-height: 0;} .selectize-dropdown { line-height: 10px; }"),
    selectInput("test","Test", 1:5)
  ),
  server = function(input, output, session) {
  }
))

请尝试发布完整的代码示例,而不是我们必须自己完成的代码的 sn-p。让我们更轻松、更快捷地尝试回答

【讨论】:

  • 感谢您的帮助! Please try to post complete code samples rather than a snippet of code that we have to complete ourselves. Makes it easier and faster for us to try to answer - 下次会记住这一点。谢谢。
  • 提供调试器的屏幕截图将显着增强这个已经正确的答案。
猜你喜欢
  • 2012-07-24
  • 1970-01-01
  • 2012-10-25
  • 1970-01-01
  • 1970-01-01
  • 2022-11-17
  • 2014-12-11
  • 2014-04-25
  • 2012-02-23
相关资源
最近更新 更多