我有一个图像,无论页面大小如何,我都希望它位于页面底部的中心。但是,使用下面的代码会将图像固定在页面的左侧而不是中心。有没有办法让我把它放在底部居中?
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
fluidRow(
column(
width = 12,
img(
src ='testfig.png',
style = 'position: fixed; bottom: 0; width: 45vh; left: auto; right: auto;'
)
)
)
)
)
server <- function(input, output, session) {
}
shiny::shinyApp(ui, server)
一种方法是使用自定义 CSS:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPage(
header = dashboardHeader(),
sidebar = dashboardSidebar(),
body = dashboardBody(
tags$style(HTML("
.bottom-centered-img {
position: fixed;
bottom: 0;
left: 0;
right: 0;
width: 45vh;
margin-left: auto;
margin-right: auto;
}
")),
fluidRow(
column(
width = 12,
img(src = 'testfig.png', class = 'bottom-centered-img')
)
)
)
)
server <- function(input, output, session) {
}
shiny::shinyApp(ui, server)