我正尝试在我 Shiny 的仪表板上实现缩放,因为当网络浏览器的 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)
最佳答案
我认为如果您修改您的 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)
关于css - ShinyDashboard - 使用 CSS 缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47783927/