[英]renderDataTable with actionButton in two shinydashboard tabs
[英]Different backgrounds on shinydashboard tabs
我想創建一個閃亮的儀表板,其中第一個選項卡的背景包含本地存儲的圖片,其余選項卡包含純白色背景。
我試圖從這里修改代碼以顯示圖像而不是顏色:
library(shiny)
library(shinydashboard)
ui <- dashboardPage(dashboardHeader(dropdownMenuOutput("notificationMenu")
),
dashboardSidebar(sidebarMenu(id='sidebar',
menuItem("Page 1", tabName = "page1"),
menuItem("Page 2", tabName = "page2")
),
uiOutput('style_tag')
),
dashboardBody(
tabItems(
tabItem(tabName = "page1", h4("Picture!",style='color:black')),
tabItem(tabName = "page2", h4('white!')
)
)
)
)
server <- function(input, output, session){
output$style_tag <- renderUI({
if(input$sidebar=='page1')
return(tags$head(tags$style(HTML('.content-wrapper {
background-image:url("~/www/background.jpg") fixed center;
}')
)
)
)
if(input$sidebar=='page2')
return(tags$head(tags$style(HTML('.content-wrapper {background-color:white;}')
)
)
)
})
}
shinyApp(ui = ui, server = server)
但是,它不起作用。 我在 CSS 位做錯了嗎? 有沒有更好的方法來實現同樣的事情?
您的路徑是從 R 工作目錄的角度來看的。 它需要從瀏覽器的角度來看。 更改此 CSS:
background-image:url("background.jpg")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.