针对不同显示器尺寸的闪亮webapp页面的自动调整

问题描述 投票:1回答:2

我已经使用R Shiny框架成功构建了一个Web应用程序。在这方面,我在Googlemap中显示了一些要点。现在,我如何自动调整html页面的高度和宽度,以使其最适合不同显示器尺寸?我也尝试将其放入html代码中。此[tags$iframe(width="1330", height="580",]部分正在Internet Explorer中使用滚动条加载页面,但在同一笔记本电脑的显示器中,在没有scrllbar的适合视图中,相同的设置在Chrome中的显示效果很好。我们如何确保它在所有浏览器和设备(如Tab,智能手机)中都能正常工作?

下面是我的代码:

内部UI.r:

 shinyUI(fluidPage(
     titlePanel("My webpage heading"),
     mainPanel(
         htmlOutput("mypage")
     )
 ))

在SERVER.r内部:

shinyServer(function(input, output) {
    addResourcePath("library", "D:/R Projects")
    output$mypage < -renderUI({
        tags$iframe(width = "1330", height = "580",
            src = "library/mypage.html")

    })
})

mypage.html源代码的顶部如下:

<html>
  <head>
    //<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />//
    <meta name="viewport" content="width=device-width">
    <meta name="viewport" content="height=device-height">
javascript html r shiny
2个回答
2
投票

自动调整是Shiny擅长的事情之一,因为它依赖于Bootstrap框架。


0
投票

我在屏幕尺寸上也遇到类似的问题。我使用屏幕的大小作为选择视图参数的条件。您可以从stackoverflow中的以下问题中找到获取屏幕尺寸的命令:How can I get the screen resolution in R

© www.soinside.com 2019 - 2024. All rights reserved.