微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

闪亮的CSS:在shinydashboard侧边栏中对齐actionButtons

我试图在shinydashboard侧边栏中放置一些actionButtons,并且需要将它们设置为在侧边栏中居中并在分配给它们的空间内水平分布.

这是一个MWE:

library(shiny)
library(shinydashboard)

foo_body = dashboardBody()
foo_header = dashboardHeader()
foo_sidebar = dashboardSidebar(
  sidebarMenu(
    menuItem(
      "A Dashboard",tabName = "tab_overview",icon = icon("gamepad")  
    )
  ),# add some buttons
  actionButton(inputId = "button1",label = "B 1",icon = icon("paper-plane")),actionButton(inputId = "button2",label = "B 2",actionButton(inputId = "button3",label = "B 3",icon = icon("paper-plane"))
)

foo_page = dashboardPage(
  header = foo_header,sidebar = foo_sidebar,body = foo_body,title = "A Dashboard"
)

shinyApp(
  ui = foo_page,server = function(input,output) {}
)

以下是我需要重新设计的应用程序的相关部分:

enter image description here

任何一般或具体的想法都会受到欢迎.

最佳答案
您可以为按钮添加样式,如此.我在按钮之间留下了1%的边距

library(shiny)
library(shinydashboard)

foo_body = dashboardBody()
foo_header = dashboardHeader()
foo_sidebar = dashboardSidebar(
  sidebarMenu(
    menuItem(
      "A Dashboard",# add some buttons  
  div(style="display:inline-block;width:32%;text-align: center;",actionButton("button1",icon = icon("paper-plane"))),div(style="display:inline-block;width:32%;text-align: center;",actionButton("button2",actionButton("button3",icon = icon("paper-plane")))

)

foo_page = dashboardPage(
  header = foo_header,output) {}
)

enter image description here

原文地址:https://www.jb51.cc/css/427384.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。