繁体   English   中英

更改一个 div R Shiny 内两个 div 的背景颜色

[英]Change background color of two div inside one div R Shiny

我想换一个背景颜色div有两个div的内部。

我在用户界面中写道:

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更改背景颜色。

任何的想法?

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

要么你需要给父容器 div 一个height要么你fluidRow包含它的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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM