你能否将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,还有一个类似的问题被提出作为最后的评论,但没有得到答复,因此我决定就这个问题发布一个帖子,因为我也有同样的问题。
对于其他元素,比如textInput字段,我通常是这样做的:
tags$style(type='text/css', "#NAMEELEMENT {background-color: green; height: 40px; border-color: #bfbfbf; width: 520px; position: relative;left: 3%}"),
您可以通过使用 # 和其输入ID 来将标记 $style 附加到元素上。干杯。
.js-irs-1
是滑块2,以此类推。 - Pork Chop