【问题标题】:Navigation bar Toggle button on left of title in R shinydashboardR Shinydashboard中标题左侧的导航栏切换按钮
【发布时间】:2018-09-01 05:32:30
【问题描述】:

我有一个使用闪亮仪表板的 R 闪亮应用程序。我想在屏幕左侧的中心和侧边栏切换按钮(带有三个水平条)中使用徽标。

我使用下面的代码在中心使用 95% 的标题宽度和徽标。但是,这会在右侧 5% 的屏幕上推动带有切换按钮的导航栏。 **如何将导航栏切换到左侧(如图所示)和带有徽标的标题栏在中心? **

dashboardHeader(title = tags$a(tags$img(src='Logo.png', height=80)), 
 titleWidth = "95%")

任何建议将不胜感激。

谢谢, 克里纳

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    可能有更好的方法,但这里有一个 hacky 选项:

    1. Conceal the logo as a dropdownMenu
    2. 将徽标移动到标题的中心using css
    3. (可选)从徽标中移除 css hover 效果

    其他dropdownMenus 保持右对齐。

    library(shiny)
    library(shinydashboard)
    
    css <- HTML(
        "/* move logo to center */
        #logo {
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
        }
        /* remove hover effect */
        #logo > a:hover {
            background-color: transparent !important;
            color: transparent !important;
        }"
    )
    
    ui <- dashboardPage(
        dashboardHeader(title = "Project Title",
                        tags$li(class = "dropdown",
                                id = "logo",
                                tags$a(tags$img(height = "20px",
                                                src="https://www.r-project.org/logo/Rlogo.png")
                                ),
                                tags$style(css)
                        ),
                        dropdownMenu(type = "messages", 
                                     badgeStatus = "primary",
                                     taskItem(value = 20, 
                                              "Example"
                                     ))
        ),
        dashboardSidebar(),
        dashboardBody()
    )
    
    server <- function(input, output, session) {
    
    }
    
    shinyApp(ui, server)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-09
      • 2016-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多