更改 shinydashboard 特定部分的背景颜色 body
Change the background color of specific part of shinydashboard body
我在下面有 .rmd
文件,我通过 shiny
应用程序显示它。我想将包含在这 6 列 space 中的整个 space 的背景颜色更改为白色,而不仅仅是标题。我怎样才能做到这一点?其余 6 列(左 3 列,右 3 列)应保持相同的颜色。
app.r
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
library(knitr)
library(rmarkdown)
dbHeader <- dashboardHeaderPlus(disable = TRUE
)
shinyApp(
ui = dashboardPagePlus(
header = dbHeader,
sidebar = dashboardSidebar(width = "0px",
sidebarMenu(id = "sidebar" # id important for updateTabItems
) ),
body = dashboardBody(
tags$head(tags$style(HTML('
h1{
font-size: 12pt;
font-family: "Montserrat Light", sans-serif;
text-align: justify;
background-color: white;
}
H1.title{
font-size: 44pt;
font-family: "Chronicle Display Light", Times, serif;
text-align: right;
background-color: white;
}
H1{
font-size: 44pt;
font-family: "Chronicle Display Light", Times, serif;
text-align: right;
background-color: white;
}
H2{
font-size: 16pt;
font-weight: bold;
font-family: "Chronicle Display Light", Times, serif;
text-align: left;
background-color: white;
}
'))),
useShinyjs(),
tags$script(HTML("$('body').addClass('fixed');")),
fluidRow(
column(3,),
column(6,
uiOutput("info")))
)
),
server<-shinyServer(function(input, output,session) {
hide(selector = "body > div > header > nav > a")
output$info <- renderUI({
isolate(HTML(markdown::markdownToHTML(knit('Information2.rmd', quiet = TRUE),fragment.only=TRUE)))
})
}
)
)
Information2.rmd
---
output:
html_document: default
pdf_document: default
---
# Participant Information
## What is this study called and who is involved?
The full title of this study is “Life, death and statins: Survival analysis of elderly general practice patients in relation to statin prescriptions”. The short title is “Life, death & statins.” The investigators are Dr Adam Hodgkins, A/Prof Judy Mullan, Dr Darren Mayne, and Prof Andrew Bonney. All investigators are affiliated with the University of Wollongong.
这可以通过添加 CSS 规则来实现
#info {
background-color: white;
}
info
是 div
标签的 id
包含你的 Rmd 的内容。
我在下面有 .rmd
文件,我通过 shiny
应用程序显示它。我想将包含在这 6 列 space 中的整个 space 的背景颜色更改为白色,而不仅仅是标题。我怎样才能做到这一点?其余 6 列(左 3 列,右 3 列)应保持相同的颜色。
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
library(shinyjs)
library(knitr)
library(rmarkdown)
dbHeader <- dashboardHeaderPlus(disable = TRUE
)
shinyApp(
ui = dashboardPagePlus(
header = dbHeader,
sidebar = dashboardSidebar(width = "0px",
sidebarMenu(id = "sidebar" # id important for updateTabItems
) ),
body = dashboardBody(
tags$head(tags$style(HTML('
h1{
font-size: 12pt;
font-family: "Montserrat Light", sans-serif;
text-align: justify;
background-color: white;
}
H1.title{
font-size: 44pt;
font-family: "Chronicle Display Light", Times, serif;
text-align: right;
background-color: white;
}
H1{
font-size: 44pt;
font-family: "Chronicle Display Light", Times, serif;
text-align: right;
background-color: white;
}
H2{
font-size: 16pt;
font-weight: bold;
font-family: "Chronicle Display Light", Times, serif;
text-align: left;
background-color: white;
}
'))),
useShinyjs(),
tags$script(HTML("$('body').addClass('fixed');")),
fluidRow(
column(3,),
column(6,
uiOutput("info")))
)
),
server<-shinyServer(function(input, output,session) {
hide(selector = "body > div > header > nav > a")
output$info <- renderUI({
isolate(HTML(markdown::markdownToHTML(knit('Information2.rmd', quiet = TRUE),fragment.only=TRUE)))
})
}
)
)
Information2.rmd
---
output:
html_document: default
pdf_document: default
---
# Participant Information
## What is this study called and who is involved?
The full title of this study is “Life, death and statins: Survival analysis of elderly general practice patients in relation to statin prescriptions”. The short title is “Life, death & statins.” The investigators are Dr Adam Hodgkins, A/Prof Judy Mullan, Dr Darren Mayne, and Prof Andrew Bonney. All investigators are affiliated with the University of Wollongong.
这可以通过添加 CSS 规则来实现
#info {
background-color: white;
}
info
是 div
标签的 id
包含你的 Rmd 的内容。