可以将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在这里的答案:进阶,类似的问题作为最终评论被问到,但没有答案,所以我决定就此问题发布一个问题,因为我有同样的问题。
对于其他元素,例如textInput字段,我通常这样做的方式是这样的:
tags$style(type='text/css', "#NAMEELEMENT {background-color: green; height: 40px; border-color: #bfbfbf; width: 520px; position: relative;left: 3%}"),
您可以在其中通过#及其inputId将tag $ style附加到元素。
干杯。
我自己找到了答案。我相信,决心,谷歌和Stackoverflow等上的大量时间与我发现由Dean Atali创建的一些信息相结合,但这似乎可以做到:
tags$head(tags$style(HTML('.selectize-input {white-space: nowrap}
#choice+ div>.selectize-dropdown{width: 660px !important}
#choices+ div>.selectize-dropdown{width: 300px !important}')))
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句