问题
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