图片未显示为闪亮应用程序中的背景

时间:2020-03-18 07:23:14

标签: css r shiny shinyapps

我正在努力将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)

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

非常感谢您提供任何指针。

1 个答案:

答案 0 :(得分:1)

您必须使用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)