ShinyDashboard - 使用CSS缩放

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

我正试图在我闪亮的仪表板上实现缩放,因为当网页浏览器的缩放率为80%时,布局看起来更好。

我发现了一篇关于SO的文章,然而,它对Shinydashboard不起作用。当我实现CSS时,我得到了很多死白空间。

文章:SO:Zoom out shiny app at default in browser

简单代码示例:

library(shiny)
library(shinydashboard)

header <- dashboardHeader()
sidebar <- dashboardSidebar()
body <- dashboardBody(
  tags$style("
              body {
             -moz-transform: scale(0.8, 0.8); /* Moz-browsers */
             zoom: 0.8; /* Other non-webkit browsers */
             zoom: 80%; /* Webkit browsers */
             }
             "),
  "test")

ui <- dashboardPage(header, sidebar, body)

server <- function(input, output, session) {}

shinyApp(ui, server)

图片显示问题(使用铬):enter image description here

css r shiny shinydashboard
1个回答
1
投票

我认为如果你修改你的ui代码会有用。当我这样做时它对我有用:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
  tags$style("
              body {
             -moz-transform: scale(0.8, 0.8); /* Moz-browsers */
             zoom: 0.8; /* Other non-webkit browsers */
             zoom: 80%; /* Webkit browsers */
             }
             ")
))

server <- function(input, output, session) {}

shinyApp(ui, server)
© www.soinside.com 2019 - 2024. All rights reserved.