【发布时间】:2017-10-24 20:16:05
【问题描述】:
您可以将 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 附加到元素。
干杯。
【问题讨论】:
-
也许这会帮助stackoverflow.com/questions/36906265/…。注意
.js-irs-0是滑块 1,.js-irs-1是滑块 2,依此类推 -
我实际上将这个答案用于我的滑块。它有效,但有一个讨厌的缺点。如果我稍后在应用程序中添加另一个滑块,我想我必须为所有 .js-irs-0 .irs-single 和 .js-irs-0 元素提供报酬。 IE。容易出错!