Image 闪亮应用程序:强制图像与侧边栏面板的宽度相同

Image 闪亮应用程序:强制图像与侧边栏面板的宽度相同,image,shiny,Image,Shiny,我是一个闪亮的新手,我有一个非常简单的问题,尽管我在谷歌上没有找到答案:我想在我的侧边栏面板中放置一个图像,并且我希望图像的宽度与侧边栏面板的宽度相同 问题是,当用户更改他们显示闪亮应用程序的窗口一侧时,侧边栏面板的宽度会自动更改,而图像的宽度保持不变 有没有像sideparPanel.width这样的函数可以用来将我的图像调整到边栏面板上 下面是我的代码,其中图像的固定宽度为500像素: library(shiny) shinyUI(fluidPage( #the title pane

我是一个闪亮的新手,我有一个非常简单的问题,尽管我在谷歌上没有找到答案:我想在我的侧边栏面板中放置一个图像,并且我希望图像的宽度与侧边栏面板的宽度相同

问题是,当用户更改他们显示闪亮应用程序的窗口一侧时,侧边栏面板的宽度会自动更改,而图像的宽度保持不变

有没有像sideparPanel.width这样的函数可以用来将我的图像调整到边栏面板上

下面是我的代码,其中图像的固定宽度为500像素:

 library(shiny)
shinyUI(fluidPage(

  #the title panel (mandatory)
  titlePanel("title"),

  sidebarLayout(
  #The sidebar panel (default position = left)
      sidebarPanel(
      img(src="myimage.png",width=500)
    ),

    #Content of the main panel
    mainPanel("blablabla"
    )
  )

))

非常感谢你的帮助

可以将宽度指定为百分比,而不是像素。比如说,

library(shiny)
shinyUI(fluidPage(

  #the title panel (mandatory)
  titlePanel("title"),

  sidebarLayout(
  #The sidebar panel (default position = left)
      sidebarPanel(
      img(src="myimage.png",width="100%")
    ),

    #Content of the main panel
    mainPanel("blablabla"
    )
  )
))

在这种情况下,图像的宽度总是相对于侧边栏的宽度。

您可以尝试执行元素绝对定位的
绝对面板。
。请指出这些答案是否解决了您的问题