繁体   English   中英

如何在R Shiny中对齐图像?

[英]How to align images in R Shiny?

我有一个闪亮的应用程序,其徽标在titlePanel中右对齐,另一个徽标在“页脚”中右对齐。 我想要两个图像都具有相同的大小,并且希望它们都右对齐到同一条“垂直线”。

library(shiny)
library(shinythemes)

shinyApp(

  ui <- fluidPage(

    theme = shinytheme("simplex"),

    titlePanel(

      div("Fancy Title",
          actionLink(inputId = "gitLab",
                     label = tags$img(src = "logo_1.svg", width = "40px", height = "40px"),
                     style = "background-size:cover; background-position:center; position:absolute;right:2em",
                     onclick = "window.open('https://github.com/')")

      )

    ), # end titlePanel

    hr(),
    div(
      width = 10,
      a(href = "https://www.rcsb.org/", "Whatever", target="_blank"),

      actionLink(inputId = "ABC",
                 label = tags$img(src = "logo_2.svg", width = "40px", height = "40px"),
                 style = "background-size:cover; background-position:center; position:absolute;right:2em",
                 onclick = "window.open('https://www.rcsb.org/')")

    ),

    br()

  ), # end fluidPage

  server = function(input, output, session){}

) # end shinyApp

到目前为止,我无法将它们向右对齐,因此它们都具有相同的“ x坐标”。 救命!

我在CSS方面的经验有限,但我相信在您的样式中添加其中之一可能会解决您的问题:

style ='float:right;'

要么

样式='text-align:right;'

要么

style ='position:absolute; 右:42px;' (调整像素以满足您的需求)

希望这可以帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM