图片未在 Shiny 应用程序中作为背景出现

Picture is not coming up as background in Shiny app

我正在努力将 SVG 图像作为 div 中某些 UI 的背景。下面是我的最小 Shiny app -

library(shiny)

ui <- fluidPage(
  div(style = "height: 100px; width: 100px; background-image: url('https://cdn.shopify.com/s/files/1/0496/1029/files/Freesample.svg') no-repeat top left;")
)
server <- function(input, output) {}
shinyApp(ui, server)

如您所见,图片未作为背景出现。

非常感谢任何指点。

您必须使用 CSS 属性 background 而不是 background-image。此外,您设置的尺寸太小,无法容纳图像。尝试:

library(shiny)

ui <- fluidPage(
  div(style = "height: 392px; width: 472px; background: url(https://cdn.shopify.com/s/files/1/0496/1029/files/Freesample.svg) no-repeat top left;")
)
server <- function(input, output) {}
shinyApp(ui, server)