![](/img/trans.png)
[英]Add a company logo right after shiny dashboard header toggle button
[英]Fix the position of the shiny dashboard header toggle button
在下面的shiny
應用程序中,我希望顯示和隱藏側邊欄的切換按鈕在其 position 中保持固定,無論側邊欄是否隱藏。 現在,當側邊欄隱藏時,按鈕和頁面開頭之間有一個藍色方形空隙。
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPage(
dashboardHeader(
titleWidth = 0
),
dashboardSidebar(
),
dashboardBody(
tags$head(tags$style(HTML('
/* navbar (rest of the header) */
.skin-blue .main-header .navbar {
background-image:url("https://www.r-project.org/logo/Rlogo.png");
background-position-x: 3%;
background-size: 170px 40px;
background-repeat: no-repeat;
background-color:#000;
}
'))),
tags$style(type="text/css",".sidebar-toggle{ position: absolute;
left: 0;
}")
),
controlbar = dashboardControlbar(id = "dashboardControlbarID", collapsed = TRUE,skin = "light"
)
)
server <- function(input, output){
}
shinyApp(ui, server)
您只需要減少左邊距 - 請參閱margin-left: 0px;important;
:
library(shiny)
library(shinydashboard)
library(shinydashboardPlus)
ui <- dashboardPage(
dashboardHeader(titleWidth = 0),
dashboardSidebar(),
dashboardBody(
tags$head(tags$style(HTML('
/* navbar (rest of the header) */
.skin-blue .main-header .navbar {
background-image:url("https://www.r-project.org/logo/Rlogo.png");
background-position-x: 3%;
background-size: 170px 40px;
background-repeat: no-repeat;
background-color:#000;
margin-left: 0px !important;
}
'))),
tags$style(type="text/css",".sidebar-toggle{position: absolute; left: 0;}")
),
controlbar = dashboardControlbar(id = "dashboardControlbarID", collapsed = TRUE,skin = "light")
)
server <- function(input, output){}
shinyApp(ui, server)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.