闪亮 - 如何更改选择标签中的字体大小?

lau*_*kok 11 r shiny

如何更改选择标签中的字体大小?

我尝试使用下面的代码,但字体大小根本没有变化.

shinyUI(fluidPage(

  sidebarPanel(

    # Change the font size.
    tags$style(type='text/css', "select {font-size: 32px !important} "),

    # Species/ pollutant options
    selectInput(
        inputId = "species",
        label = "Species:",
        choices = c(...)
        ),
   ....
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Dea*_*ali 21

您有正确的想法,但有光泽的选择输入实际上使用选择性JavaScript来显示UI而不是传统的selectHTML标记.这就是你的CSS没有捕获的原因.

你想要的而不是selectCSS".selectize-input { font-size: 32px; }

但是,如果你只有那个CSS,那么下拉菜单选项仍然是默认大小,并且文本周围也没有填充看起来很尴尬.这是您可能想要使用的一些CSS:

.selectize-input { font-size: 32px; line-height: 32px;}
.selectize-dropdown { font-size: 28px; line-height: 28px; }
Run Code Online (Sandbox Code Playgroud)

因此,将其添加到应用程序会给出:

runApp(shinyApp(
  ui = fluidPage(
    tags$style(type='text/css', ".selectize-input { font-size: 32px; line-height: 32px;} .selectize-dropdown { font-size: 28px; line-height: 28px; }"),
    selectInput("test","Test", 1:5)
  ),
  server = function(input, output, session) {
  }
))
Run Code Online (Sandbox Code Playgroud)