您可以将 css 样式应用到单个 selectInput 菜单吗?
我在其他文章中找到了处理 selectInput 菜单样式的代码,但结果会影响应用程序中的所有内容。我只想操作单独的菜单。
我还在考虑根据服务器中发生的条件向各个元素添加样式,但这是另一个单独的问题。
测试应用程序代码:
library(shiny)
library(shinydashboard)
library(shinyjs)
ui <-
fluidPage(
hr("how do we get the change the style elements of a single select input?)
tags$style(type='text/css', .selectize-input { font-size: 8px; line-height: 8px;}
.selectize-dropdown { font-size: 8px; line-height: 8px; }"),
selectInput("choice", "choices", c("A", "B", "C")),
selectInput("choice2", "choices", c("D", "E", "F"))
)
server < - function(input, output, session) { }
})
shinyApp(ui = ui, server = server)
这种方法直接来自 Dean Attali 的回答:examp,并提出了一个类似的问题作为最终评论,但没有答案,所以我决定就此事发布一个问题,因为我有同样的问题。
对于文本输入字段等其他元素,我通常这样做的方式是:
tags$style(type='text/css', "#NAMEELEMENT {background-color: green; height: 40px; border-color: #bfbfbf; width: 520px; position: relative;left: 3%}"),
您可以在其中通过 # 及其 inputId 将 tag$style 附加到元素。
Cheers.