css 修复ShinyApp中Slick R旋转木马图像的大小

m3eecexj  于 2022-12-05  发布在  其他
关注(0)|答案(1)|浏览(123)

我有一个带有slickR轮播的shinyApp,可以显示不同的图像。这些图像有不同的大小。大的图像会破坏整体外观。有没有办法修复slickR容器的大小,使图像适应这个大小?任何帮助都将不胜感激。下面是一个示例应用程序:

library(shiny)
library(slickR)

ui <- fluidPage(#The last image breaks the overall appearance
  slickR::slickR(slick_div(c("https://cdn.pixabay.com/photo/2018/07/31/22/08/lion-3576045__340.jpg",
                             "https://cdn.pixabay.com/photo/2012/02/27/15/35/lion-17335__340.jpg",
                             "https://cdn.pixabay.com/photo/2018/02/01/12/51/lion-3123179__340.jpg",
                             "https://www.aprenderjuntos.cl/wp-content/uploads/2020/08/LEON-SERIO-.jpg")), height = "800px") + #height argument does not seem to do anything
    settings(autoplay = TRUE)
)

server <- function(input, output, session) {
  
}

shinyApp(ui, server)
von4xj4u

von4xj4u1#

您可以使用slick_list来包含一些具有指定高度的img标签:

library(shiny)
library(slickR)

ui <- fluidPage(
  slickR(slick_list(
    tags$img(
      src = "https://cdn.pixabay.com/photo/2018/07/31/22/08/lion-3576045__340.jpg",
      height = 500
    ),
    tags$img(
      src = "https://cdn.pixabay.com/photo/2012/02/27/15/35/lion-17335__340.jpg",
      height = 500
    ),
    tags$img(
      src = "https://cdn.pixabay.com/photo/2018/02/01/12/51/lion-3123179__340.jpg", 
      height = 500
    ),
    tags$img(
      src = "https://www.aprenderjuntos.cl/wp-content/uploads/2020/08/LEON-SERIO-.jpg",
      height = 500
    )
  )) + settings(autoplay = TRUE)
)

server <- function(input, output, session) {}

shinyApp(ui, server)

相关问题