【问题标题】:Selectize Input style in shiny (for two different selectize boxes)选择闪亮的输入样式(用于两个不同的选择框)
【发布时间】:2017-06-21 22:56:15
【问题描述】:

最近有人帮我解决了这个问题:Selectize Input style in shiny。现在,我想更进一步,还有另一个问题。

我有两个selectize inputs。我想分别更改每个选择器的选定项目的颜色。这是澄清我的问题的图片。

我有什么:

以及我想获得什么:

我尝试使用 id 和类的不同组合更改我的 css,但没有成功。你能帮帮我吗?

我的代码:

server.R:

library("shiny")

shinyServer(function(input, output){})

ui.R:

library("shiny")

shinyUI(fluidPage(

    tags$head(
        tags$style(HTML("
                        .item {
                        background: #2196f3 !important;
                        }
                        .selectize-dropdown-content .active {
                        background: #2196f3 !important;
                        }
                        "))
        ),

    sidebarLayout(
        sidebarPanel(
            selectizeInput("select", label=NULL,
                           choices=c("a", "b", "c", "d"),
                           multiple=TRUE, options=list(placeholder="Wybierz")),
            selectizeInput("select2", label=NULL,
                           choices=c("a", "b", "c", "d"),
                           multiple=TRUE, options=list(placeholder="Wybierz"))),

        mainPanel())
    )
)

【问题讨论】:

    标签: html css r shiny


    【解决方案1】:

    你需要类似的东西

       tags$style(HTML(" .item {
                        background: #2196f3 !important;
                        }
    
                        #select2 + div> div>.item {
                        background:   #f3217a !important;
                        }
                        .selectize-dropdown-content .active {
                        background: #2196f3 !important;
                        }
    
                         #select2 + div> div>.selectize-dropdown-content .active {
                        background:   #f3217a !important;
                        }
                        "))
    

    在你的 CSS 中

    select2 将不同于所有其他“选择”

    或为每个#select定义颜色

    PS 你可以在服务器端使用应用和粘贴(如1 在更新中查看)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-16
      • 1970-01-01
      • 2018-08-02
      • 1970-01-01
      • 2015-05-06
      • 2018-10-01
      • 2016-04-03
      • 1970-01-01
      相关资源
      最近更新 更多