从Shinywidget包中定位特定的下拉CSS

时间:2018-09-18 10:49:26

标签: css r shiny

我正在努力寻找如何以CSS样式代码为目标的两个下拉菜单中的一个。 我可以为下拉菜单设置总体样式,但不能单独设置

我已尝试通过以下方式将其作为目标,但没有任何效果。

#MyDropDown1 .sw-show.sw-dropdown-content {       

#sw-content-MyDropDown1 .sw-show.sw-dropdown-content {

.dropdown-content-MyDropDown1 {

#dropdown-content-MyDropDown1 {

#dropdown-menu-MyDropDown1 {

如何找到针对第一个下拉菜单的正确语法?

这是应用程序:

  library(shiny)
  library(shinyWidgets)

  ui <- fluidPage(

    tags$head(tags$style(HTML('
     .sw-show.sw-dropdown-content {
    display: block;
    left: 200px;
    top: 100px;
height: 300px;
width:
    } '))),

    dropdown(inputId = "MyDropDown1",
             tags$h3("List of Input")),
  dropdown(inputId = "MyDropDown2",
           tags$h3("List of Input"))
  )
  server <- function(input, output, session){
  }

  shinyApp(ui = ui, server = server)

1 个答案:

答案 0 :(得分:0)

也许这是一条路。但不幸的是,由于利润的缘故,我最终只能买到2盒... 但至少CSS样式仅适用于第一个下拉菜单

library(shiny)
library(shinyWidgets)

ui <- fluidPage(

    tags$head(tags$style(HTML('
                              .test {
                              display: block;
                              background-color:red;
                              left: 200px;
                              top: 100px;
                              height: 300px;
                              width:
                              } '))),

    dropdown(inputId = "MyDropDown1",
             tags$h3("List of Input"), class = "test"),
    dropdown(inputId = "MyDropDown2",
             tags$h3("List of Input"))
    )
server <- function(input, output, session){
}

shinyApp(ui = ui, server = server)
相关问题