Centering images horizontally in a shiny fluidRow

前端 未结 2 1989
盖世英雄少女心
盖世英雄少女心 2021-01-15 05:05

Is it possible to centre three images in one row within the shiny ui fluidPage AND have the width of each image fixed at 300px? To get:

One idea I had was t

相关标签:
2条回答
  • 2021-01-15 05:51

    Something like this?

    rm(list = ls())
    library(shiny)
    
    server = function(input, output, session) {}
    
    ui <- fluidPage(fluidRow(
      #Change column(x, for desired width
      column(6,
             div(style="display: inline-block; width: 33%;",img(src="https://cran.r-project.org/Rlogo.svg", height=300, width=300)),
             div(style="display: inline-block; width: 33%;",img(src="https://cran.r-project.org/Rlogo.svg", height=300, width=300)),
             div(style="display: inline-block; width: 33%;",img(src="https://cran.r-project.org/Rlogo.svg", height=300, width=300))))
    )
    
    
    shinyApp(ui = ui, server = server)
    

    0 讨论(0)
  • 2021-01-15 05:53

    I managed to fix it using the column function, I was simply missing the align="center" argument paired with the removal of the width argument in the style. For example:

    library(shiny)
    
    server = function(input, output, session) {}
    
    ui <- fluidPage(fluidRow(
             column(12, align="center",
                    div(style="display: inline-block;",img(src="image1", height=300, width=300)),
                    div(style="display: inline-block;",img(src="image2", height=300, width=300)),
                    div(style="display: inline-block;",img(src="image3", height=300, width=300))))
    )
    
    
    shinyApp(ui = ui, server = server)
    
    0 讨论(0)
提交回复
热议问题