在 R shiny 中更改流体页面的背景颜色
Change Background color of fluid page in R shiny
我有一个 cerulean 主题的闪亮流体页面,其中有两个 fluidRows 一个内嵌另一个。第一个 fluidRow 放置图像,第二个 fluidRow 将文本放置在图像下方。下面是 UI 代码:
fluidPage(theme = shinytheme("cerulean"),
fluidRow(column(12,align ="center",
div(img(src="test.png", height=200, width=300))),
fluidRow(column(12, align = 'center',
div(style = "font-size: 20px; padding: 0px 0px; margin-top:-2em"),
titlePanel(title = 'Express', windowTitle = 'Express Plots'))
)#closefluidRow
)#closefluidRow
) #closefluidPage
在这里,带有图像和标题面板的 fluidRows 的背景颜色是白色,我需要在背景中使用蓝色(天蓝色)。
有人可以暗示实现这一点。
看起来 shinytheme 只是让文本变得蔚蓝。请尝试以下操作:
library(shiny)
ui <- fluidPage(
tags$style('.container-fluid {
background-color: #007BA7;
}'),
fluidRow(column(12,align ="center",
div(img(src="test.png", height=200, width=300))),
fluidRow(column(12, align = 'center',
div(style = "font-size: 20px; padding: 0px 0px; margin-top:-2em"),
titlePanel(title = 'Express', windowTitle = 'Express Plots'))
)#closefluidRow
)#closefluidRow
#closefluidPage
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
您可以使用十六进制颜色 #007BA7。我从 cerulean wiki.
得到的
您还可以将 background-color: #007BA7;
添加到 div(style = ...)
更新
基于以下评论。要将 cerulean 限制为 fluidPage 添加一个 id 并限制样式如下:
library(shiny)
ui <- fluidPage(id = 'test',
tags$style('#test {
background-color: #007BA7;
}'),
fluidRow(column(12,align ="center",
div(img(src="test.png", height=200, width=300))),
fluidRow(column(12, align = 'center',
div(style = "font-size: 20px; padding: 0px 0px; margin-top:-2em"),
titlePanel(title = 'Express', windowTitle = 'Express Plots'))
)#closefluidRow
)#closefluidRow
#closefluidPage
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
我有一个 cerulean 主题的闪亮流体页面,其中有两个 fluidRows 一个内嵌另一个。第一个 fluidRow 放置图像,第二个 fluidRow 将文本放置在图像下方。下面是 UI 代码:
fluidPage(theme = shinytheme("cerulean"),
fluidRow(column(12,align ="center",
div(img(src="test.png", height=200, width=300))),
fluidRow(column(12, align = 'center',
div(style = "font-size: 20px; padding: 0px 0px; margin-top:-2em"),
titlePanel(title = 'Express', windowTitle = 'Express Plots'))
)#closefluidRow
)#closefluidRow
) #closefluidPage
在这里,带有图像和标题面板的 fluidRows 的背景颜色是白色,我需要在背景中使用蓝色(天蓝色)。 有人可以暗示实现这一点。
看起来 shinytheme 只是让文本变得蔚蓝。请尝试以下操作:
library(shiny)
ui <- fluidPage(
tags$style('.container-fluid {
background-color: #007BA7;
}'),
fluidRow(column(12,align ="center",
div(img(src="test.png", height=200, width=300))),
fluidRow(column(12, align = 'center',
div(style = "font-size: 20px; padding: 0px 0px; margin-top:-2em"),
titlePanel(title = 'Express', windowTitle = 'Express Plots'))
)#closefluidRow
)#closefluidRow
#closefluidPage
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
您可以使用十六进制颜色 #007BA7。我从 cerulean wiki.
得到的您还可以将 background-color: #007BA7;
添加到 div(style = ...)
更新
基于以下评论。要将 cerulean 限制为 fluidPage 添加一个 id 并限制样式如下:
library(shiny)
ui <- fluidPage(id = 'test',
tags$style('#test {
background-color: #007BA7;
}'),
fluidRow(column(12,align ="center",
div(img(src="test.png", height=200, width=300))),
fluidRow(column(12, align = 'center',
div(style = "font-size: 20px; padding: 0px 0px; margin-top:-2em"),
titlePanel(title = 'Express', windowTitle = 'Express Plots'))
)#closefluidRow
)#closefluidRow
#closefluidPage
)
server <- function(input, output, session) {
}
shinyApp(ui, server)