ShinyDashboard - Zoom with CSS

假如想象 提交于 2019-12-24 07:53:18

问题


I am trying to implement zoom on my shiny dashboard as the layout looks better when it is at 80% zoom for the web browser.

I found an article on SO, however, it doesn't work for Shinydashboard. When I implement the CSS, I get a lot of dead white space.

Article to SO: Zoom out shiny app at default in browser

Simple Code Example:

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)

Picture showing problem (using chrome):


回答1:


I think it will work if you modify your ui code some. It works for me when I do it this way:

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)


来源:https://stackoverflow.com/questions/47783927/shinydashboard-zoom-with-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!