Adjust height of the whole header bar in dashboardHeader in shiny dashboard

空扰寡人 提交于 2019-12-19 04:45:15

问题


I have seen that there is a similar question here :

Adjust height of dashboardheader in shinydashboard

but I don't have the reputation to comment on the given answer.

The solution given to this answer will work in the case where I want to expand the size of the header. However when I reduce the size to 20 pixels this only changes the height of the title section of the header, I would like to reduce the height of the whole header bar in the shiny dashboard. Is this possible ?

Here is an example using the solution to the question mentioned:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(
    # Set height of dashboardHeader
    tags$li(class = "dropdown",
            tags$style(".main-header {max-height: 20px}"),
            tags$style(".main-header .logo {height: 20px}")
    ) 
  ),
   dashboardSidebar(
    # Adjust the sidebar
    tags$style(".left-side, .main-sidebar {padding-top: 20px}")
  ),
  dashboardBody()
)

server <- function(input, output){}

shinyApp(ui, server)

回答1:


You need to override the min-height of the navbar and padding on the sidebar-toggle. I have updated your example below:

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(
    # Set height of dashboardHeader
    tags$li(class = "dropdown",
            tags$style(".main-header {max-height: 20px}"),
            tags$style(".main-header .logo {height: 20px;}"),
            tags$style(".sidebar-toggle {height: 20px; padding-top: 1px !important;}"),
            tags$style(".navbar {min-height:20px !important}")
    ) 
  ),
   dashboardSidebar(
    # Adjust the sidebar
    tags$style(".left-side, .main-sidebar {padding-top: 20px}")
  ),
  dashboardBody()
)

server <- function(input, output){}

shinyApp(ui, server)


来源:https://stackoverflow.com/questions/41504337/adjust-height-of-the-whole-header-bar-in-dashboardheader-in-shiny-dashboard

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