调整操作按钮的大小会导致 shinydashboard 中的 header 错位
resizing an action button causes misalignment in the header in shinydashboard
我在 shinydashboard 的 header 上放置了一个操作按钮,它会自动打开默认邮件应用程序并填写收件人:行。但是,当我调整按钮大小时,可折叠侧边栏 header 和主要 header 会错位(请参阅下图作为参考)。
此外,我已经在 SO 中查看了这些帖子:
- Aligning a text with variable length in the middle of dashboard header
然而,跟随他们并没有为我的问题提供足够的帮助。这是代表:
library(shiny)
library(shinydashboard)
library(shinyjs)
library(shinydashboardPlus)
library(htmltools)
library(DT)
ui <- shinydashboardPlus::dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
header = shinydashboardPlus::dashboardHeader(disable = FALSE,
tags$li(class = "dropdown",
tags$a(actionButton(inputId = "email1", label = "",
icon = icon("envelope", lib = "font-awesome")
,
style='height: 20px; width: 30px;
margin-top: 0px; margin-right: 0px;
margin-bottom: 0px; padding:4px 4px 20px 4px;'
),
href="mailto:my_awesome_email_address.com")),
title = tagList(
tags$span(
class = "logo-mini", "small"
),
tags$span(
class = "logo-lg", "LONGER TEXT"
)
)),
sidebar = shinydashboardPlus::dashboardSidebar(
minified= TRUE,
collapsed = TRUE,
sidebarMenu(
),
tags$script(JS("document.getElementsByClassName('sidebar-toggle')[0].style.visibility = 'hidden';"))
),
body = shinydashboard::dashboardBody(
tabItems(
tabItem(tabName = "mainPanel_1",
box(
)
)
),
controlbar = NULL,
footer = NULL
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
任何帮助或提示将不胜感激。
为您的按钮使用此样式:
style='height: 20px;
background: transparent;
border: none;
font-size: 2rem;
transform: translate(5%, -30%);'
我在 shinydashboard 的 header 上放置了一个操作按钮,它会自动打开默认邮件应用程序并填写收件人:行。但是,当我调整按钮大小时,可折叠侧边栏 header 和主要 header 会错位(请参阅下图作为参考)。
此外,我已经在 SO 中查看了这些帖子:
- Aligning a text with variable length in the middle of dashboard header
然而,跟随他们并没有为我的问题提供足够的帮助。这是代表:
library(shiny)
library(shinydashboard)
library(shinyjs)
library(shinydashboardPlus)
library(htmltools)
library(DT)
ui <- shinydashboardPlus::dashboardPage(
options = list(sidebarExpandOnHover = TRUE),
header = shinydashboardPlus::dashboardHeader(disable = FALSE,
tags$li(class = "dropdown",
tags$a(actionButton(inputId = "email1", label = "",
icon = icon("envelope", lib = "font-awesome")
,
style='height: 20px; width: 30px;
margin-top: 0px; margin-right: 0px;
margin-bottom: 0px; padding:4px 4px 20px 4px;'
),
href="mailto:my_awesome_email_address.com")),
title = tagList(
tags$span(
class = "logo-mini", "small"
),
tags$span(
class = "logo-lg", "LONGER TEXT"
)
)),
sidebar = shinydashboardPlus::dashboardSidebar(
minified= TRUE,
collapsed = TRUE,
sidebarMenu(
),
tags$script(JS("document.getElementsByClassName('sidebar-toggle')[0].style.visibility = 'hidden';"))
),
body = shinydashboard::dashboardBody(
tabItems(
tabItem(tabName = "mainPanel_1",
box(
)
)
),
controlbar = NULL,
footer = NULL
)
)
server <- function(input, output, session) {
}
shinyApp(ui, server)
任何帮助或提示将不胜感激。
为您的按钮使用此样式:
style='height: 20px;
background: transparent;
border: none;
font-size: 2rem;
transform: translate(5%, -30%);'