Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 闪亮的仪表板顶部的页锁仪表板标题_Css_R_Shiny - Fatal编程技术网

Css 闪亮的仪表板顶部的页锁仪表板标题

Css 闪亮的仪表板顶部的页锁仪表板标题,css,r,shiny,Css,R,Shiny,我使用R闪亮的仪表板页面构建交互式仪表板。我想锁定仪表板标题和侧边栏菜单,以便在滚动时,标题和侧边栏保持在同一位置 对于侧边栏菜单,这可以在CSS中完成: .skin-blue .main-sidebar { position: fixed; overflow: visible; } 但是,当您对dashboardHeader尝试相同的技巧时,它失败了。它将下拉菜单(通知图标)放置在左侧,而不是右上角 如何在不更改闪亮应用程序的设计的情况下修复标题 最简单的工作示例: 附录R: ##

我使用R闪亮的仪表板页面构建交互式仪表板。我想锁定仪表板标题和侧边栏菜单,以便在滚动时,标题和侧边栏保持在同一位置

对于侧边栏菜单,这可以在CSS中完成:

.skin-blue .main-sidebar {
  position: fixed; 
  overflow: visible;
}
但是,当您对dashboardHeader尝试相同的技巧时,它失败了。它将下拉菜单(通知图标)放置在左侧,而不是右上角

如何在不更改闪亮应用程序的设计的情况下修复标题

最简单的工作示例:

附录R:

## app.R ##
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard",
    dropdownMenu(type = "messages",
      messageItem(
        from = "Sales Dept",
        message = "Sales are steady this month."
      )
    )
  ),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Dashboard", tabName = "dashboard", icon = icon("dashboard")),
      menuItem("Widgets", tabName = "widgets", icon = icon("th"))
    )
  ),
  dashboardBody(
    ## Add some CSS shit to change colors, width, etc.
    tags$head(
      tags$link(rel = "stylesheet", type = "text/css", href = "custom.css")
    ),
    fluidRow(
      box(plotOutput("plot1", height = 2500))
    )
  )
)

server <- function(input, output) {
  histdata <- rnorm(500)

  output$plot1 <- renderPlot({
    data <- histdata[1:50]
    hist(data)
  })
}

shinyApp(ui, server)
AdminLte(shinydashboard使用的框架)有一个固定的布局(请参阅),您可以在应用程序中通过在UI中的某个位置放置以下行来激活它:

tags$script(HTML("$('body').addClass('fixed');"))
(例如在
仪表板主体中)


注意:这将对页眉和侧边栏应用固定布局。

非常有效!谢谢!我怎样才能把它和固定宽度的包装结合起来呢?我希望我的仪表板的最大宽度为2000px。因此,在我的css中,我加入了
.wrapper{width:2000px;left:auto;margin right:auto;}
。在高分辨率显示器上,这会导致左侧边栏位于包装器外部的绝对左侧。挣扎了几个小时来解决这个问题。。。有什么建议吗?我不认为这是可能的。。。有一个“盒式布局”(boxed layout),但它不适用于“固定布局”,您必须选择。尽管如此,您仍然可以在正文上添加一个最大宽度(但侧边栏仍将位于左侧):
tags$style(HTML(“.content{max-width:1200px;margin:auto;}”)
tags$script(HTML("$('body').addClass('fixed');"))