r - 图片作为 Shiny 仪表板的背景

标签 r shiny background shinydashboard

我想在我 Shiny 的仪表板应用程序中更改背景。我在互联网功能 setBackgroundImage ( https://rdrr.io/cran/shinyWidgets/man/setBackgroundImage.html ) 中受伤。问题是我不知道我是否应该将该功能放在我的应用程序中。例如是经典应用程序,而不是仪表板。

library(shiny)
library(shinydashboard)
library(shinyWidgets)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(
    setBackgroundImage(src = "http://wallpics4k.com/wp-content/uploads/2014/07/470318.jpg")
  )
)
server <- function(input, output) {}
shinyApp(ui, server)

也可以将传单 map 作为背景吗?

最佳答案

你可以用 tags$img() 来做,并将位置属性指定为绝对。注意 img 标签必须放在 dashboardBody 中的第一个位置:

...
  dashboardBody(
    tags$img(
      src = "http://wallpics4k.com/wp-content/uploads/2014/07/470318.jpg",
      style = 'position: absolute'
    ),
    ...
  )
...

它还接受 widthheight参数。您还可以使用 hspace 定位您的图像和 vspace参数。

关于r - 图片作为 Shiny 仪表板的背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54568428/

相关文章:

R Shiny : Prevent cssloader from showing until action button is clicked

r - 如何将条件面板设置为 Shiny 的选择输入?

html - Shiny 中 selectInput 标签旁边的信息图标

css - 具有 CSS 定位的多个背景

r - 通过循环从数据帧填充矩阵

r - 根据下一行条件删除R中的一行

html - ShinyDashboard 仪表板标题与浏览器中的 Logo 不符

r - 绘图条形图,为着色、不透明度或边框颜色添加第二个因素

swift - NSTimer 在后台绘制 barChart

html - 设置 css 背景边距