【问题标题】:Shiny selectInput label CSS闪亮的 selectInput 标签 CSS
【发布时间】:2020-01-15 19:35:31
【问题描述】:

我正在创建带有蓝色标题的白色 div,但是当我将 selectInput 放入 div 时,我想要蓝色的标题是 selectInput 标签。

如何编辑下面用于创建块的代码,以使TO_BLUE 框与BLUE 块具有相同的样式?

library(shiny)

# I have two blocks BLUE and TO_BLUE
blocks <- c("BLUE", "TO_BLUE")

BLOCK <- function(data, name)
{
  # create a white div with rounded edges
  # the title of the div will have a blue background
  div(style = "
      text-align: center;
      font-size: 12px;
      background-color: white;
      border-radius: 10px;
      color: black;
      margin-bottom: 15px;
      min-height: 55px;
      ",
      id = name,

      if (name == "BLUE") {
        # this div gives the "BLUE" block it's blue background
        div(style = "background-color: #0c283b;
            color: white;
            border-top-left-radius: 10px;
            border-top-right-radius: 10px;
            min-width: 70px;",
            name)
      } else {
        # but how do I get the TITLE within the selectInput to be blue like the block above?
        selectInput(name, "TO_BLUE", choices = c("1", "2", "3", selectize = FALSE))
      }

  )
}

ui <- fluidPage(


   sidebarLayout(
      sidebarPanel(
        lapply(blocks, BLOCK, data = blocks)
      ),

      mainPanel()
   )
)

server <- function(input, output) {
}

shinyApp(ui = ui, server = server)

【问题讨论】:

    标签: css shiny


    【解决方案1】:

    使用shinyjs我添加了

    inlineCSS(".control-label { 
                background-color: #0c283b; 
                width: 100%; 
                color: white;
                border-top-left-radius: 10px;
                border-top-right-radius: 10px;
                }")
    

    【讨论】:

      猜你喜欢
      • 2016-03-01
      • 2018-11-28
      • 2018-08-24
      • 2019-01-24
      • 2015-05-07
      • 2017-03-23
      • 1970-01-01
      • 2016-10-08
      • 2019-03-20
      相关资源
      最近更新 更多