【问题标题】:Change background color of two div inside one div R Shiny更改一个 div 内两个 div 的背景颜色 R Shiny
【发布时间】:2021-12-05 18:09:45
【问题描述】:

我想更改一个div 的背景颜色,它里面有两个div

我在 UI 中写过:

div(
       div(fileInput(inputId = "file1",
                     label = "File 1"),
           style="min-width:200px;max-width:45%; float:left; margin-right:2.5%;"),
                             
       div(fileInput(inputId = "file21",
                     label = "File 2,1"),
           fileInput(inputId = "file22",
                     label = "File 2,2"),
           style="min-width:200px;max-width:45%; float:left;"),
   style = "width: 100%; background-color:#ADD8E6;"),

但是颜色没有变化。 当我将背景颜色更改为每个单独的 div 时,它确实有效。但它看起来不太好。 这就是为什么我想在更大的div 中更改背景颜色。

有什么想法吗?

也许这是实现这一目标的另一种方式。

【问题讨论】:

    标签: html css r shiny shinydashboard


    【解决方案1】:

    要么你需要给那个父容器 div 一个 height 或者你设置包含它的 fluidPage / fluidRow

    library(shiny)
    
    ui <- fluidPage(
      div(
        div(fileInput(inputId = "file1",
                      label = "File 1"),
            style="min-width:200px;max-width:45%; float:left; margin-right:2.5%;"),
        
        div(fileInput(inputId = "file21",
                      label = "File 2,1"),
            fileInput(inputId = "file22",
                      label = "File 2,2"),
            style="min-width:200px;max-width:45%; float:left;"),
        # style = "width: 100%; background-color:#ADD8E6;") # height: 500px;
      ),
      style = "width: 100%; background-color:#ADD8E6;"
    )
    
    server <- function(input, output, session) {
      
    }
    
    shinyApp(ui, server)
    

    【讨论】:

    • 我使用了fluidPage而不是div。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-06-13
    • 1970-01-01
    • 2019-05-27
    • 2021-09-16
    • 1970-01-01
    • 2020-08-25
    • 2019-04-17
    • 1970-01-01
    相关资源
    最近更新 更多