![](/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.