html - 为所有页面应用背景颜色,包括 Shiny 中的导航栏
问题描述
在下面的代码中,我尝试在所有闪亮的 UI 页面中设置背景颜色,但我无法为导航栏执行此操作:
library(shiny)
ui <- fluidPage(
setBackgroundColor(
color = c("#F7FBFF", "#2171B5"),
gradient = "linear",
direction = c("bottom","left")
),
titlePanel("Titulo"),
navbarPage(
title = h1('Métodos'),
tabPanel(h1('Painel Geral')),
tabPanel(h1('Painel Geral')),
tabPanel(h1('Painel Geral')),
tabPanel(h1('Painel Geral'))))
server <- function(input, output) {
}
shinyApp(ui = ui, server = server)
如您所见,导航栏仍然是灰色的。如何更改整个页面?
另外如何使用 .css 文件更改它?
我尝试了所有divs
但没有奏效。
有什么帮助吗?
非常感谢
解决方案
使用这个 CSS:
library(shinyWidgets)
library(shiny)
css <- "
.navbar-default {
background-color: inherit;
border: none;
}
"
ui <- fluidPage(
tags$head(tags$style(css)),
setBackgroundColor(
color = c("#F7FBFF", "#2171B5"),
gradient = "linear",
direction = c("bottom","left")
),
......
如果您不想使用shinyWidgets::setBackgroundColor
,请使用此 css:
css <- "
body {
min-height: 100%;
width:100%;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
position: absolute;
background: -moz-linear-gradient(to bottom left, #F7FBFF, #2171B5) fixed;
background: -webkit-linear-gradient(to bottom left, #F7FBFF, #2171B5) fixed;
background: -ms-linear-gradient(to bottom left, #F7FBFF, #2171B5) fixed;
background: -o-linear-gradient(to bottom left, #F7FBFF, #2171B5) fixed;
background: linear-gradient(to bottom left, #F7FBFF, #2171B5) fixed;
}
.navbar-default {
background-color: inherit;
border: none;
}
"
推荐阅读
- javascript - javascript将数字四舍五入到小数点后两位
- go - 使用 golang dep 来自同一 github 源的不同包版本
- wordpress - 使用 URL 搜索附件 ID(区分大小写)
- python - 图像分割后如何校正边界
- c++ - QHeaderview 中的排序指示器是什么?
- apache - Apache / mod_gnutls / GnuTLS 的 TLS 失败
- python - Python - 来自类实例数组的成员变量数组
- c# - DataBinding XML - 无法绑定到数据源
- javascript - 触摸并拖动取消点击桌面 Chrome
- javascript - 开玩笑 - 你如何测试状态属性已随 Styled 组件发生变化