如何更改面板颜色?

时间:2019-08-20 16:46:37

标签: r shiny

如何更改面板的面板颜色?如下图所示,我可以通过如下所示的css代码更改背景颜色,但不能如图所示更改面板。

enter image description here 我可以更改背景颜色。但是我不能改变面板的颜色。

以下代码是可复制的示例。 我应该添加什么CSS代码来更改面板的颜色。

   library(shiny)

    # Define UI for application that draws a histogram
    ui <- fluidPage(
        shiny::tags$head(
            # shinythemes::themeSelector()

                              shiny::tags$style(shiny::HTML("


            h1{
              font-size: 35px;
              font-weight: bold;
              font-family: Arial-Black;

              color: #800000            ;

            }

            h2 {
              font-size: 33px;
              font-weight: bold;
              font-family: ACalibri;

              color: #800000            ;

            }

            h3 {
              font-size: 30px;
              font-weight: bold;
              font-family: Calibri;

              color: #800000            ;

            }

            h4 {
              font-size: 27px;
              font-weight: bold;
              font-family: Calibri;

              color: #800000            ;

            }



            h5 {
              font-size: 24px;
              font-weight: bold;
              font-family: Calibri;

              color: #800000            ;

            }



            h6 {
              font-size: 15px;
              font-weight: bold;
              font-family: Arial-Black;

              color: #800000            ;

            }



            img {
                border:0;
            }


            body {
              font-size: 18px;
                 font-weight:bolder;

              font-family: Calibri;


              color: #800000            ;
             font-color: #888889;

             background-color: #222222;



            }


                                           .skin-blue .main-header .logo {
                                            background-color: #f4b943;
                                            }









            p {
                color: #440000      ;
            }




                "))

        ),#taghead
        # Application title
        titlePanel("Old Faithful Geyser Data"),

        # Sidebar with a slider input for number of bins 
        sidebarLayout(
            sidebarPanel(
                sliderInput("bins",
                            "Number of bins:",
                            min = 1,
                            max = 50,
                            value = 30)
            ),

            # Show a plot of the generated distribution
            mainPanel(
               plotOutput("distPlot")
            )
        )
    )

    # Define server logic required to draw a histogram
    server <- function(input, output) {

        output$distPlot <- renderPlot({
            # generate bins based on input$bins from ui.R
            x    <- faithful[, 2]
            bins <- seq(min(x), max(x), length.out = input$bins + 1)

            # draw the histogram with the specified number of bins
            hist(x, breaks = bins, col = 'darkgray', border = 'white')
        })
    }

    # Run the application 
    shinyApp(ui = ui, server = server)

请让我知道任何想法。

1 个答案:

答案 0 :(得分:1)

如果您想更改整个sidebarPanel的颜色,可以直接在R代码中执行此操作:

sidebarPanel(
  style = "background-color: red;",
  sliderInput(
    "bins",
    "Number of bins:",
    min = 1,
    max = 50,
    value = 30
  )
)

此外,您可以在CSS片段中添加以下段落:

.well {
  background-color: red;
}