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

时间:2015-05-29 06:09:28

标签: 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(...)
        ),
   ....

有什么想法吗?

2 个答案:

答案 0 :(得分:19)

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

您想要的不是select CSS,而是".selectize-input { font-size: 32px; }

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

.selectize-input { font-size: 32px; line-height: 32px;}
.selectize-dropdown { font-size: 28px; line-height: 28px; }

因此,将其添加到应用程序即可:

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) {
  }
))

答案 1 :(得分:0)

在选择之前添加(#)也可以解决您的问题。

标记$ style(type ='text / css',“#select {font-size:32px!important}”),