【问题标题】:Set button position in shinydashboard sidebar在闪亮仪表板侧边栏中设置按钮位置
【发布时间】:2019-07-02 20:13:08
【问题描述】:

我有一个非常基本的闪亮仪表板,我想将这个actionbutton 的位置设置在侧边栏的中间。它与侧边栏两侧的距离必须完全相同。

app.R

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(
title="Select Data to View or Download",
      titleWidth = 335),
  dashboardSidebar(
width = 335,
actionButton("load","Apply Selections")),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)

【问题讨论】:

    标签: r shiny shinydashboard


    【解决方案1】:

    一种更简单的方法(并且居中而不偏移)是使用 style 参数设置按钮位置。

    actionButton("load", "Apply Selections", style='margin:auto')
    

    【讨论】:

      【解决方案2】:

      这可以通过将其放入column 并设置align = "center" 来完成。

      library(shiny)
      library(shinydashboard)
      
      ui <- dashboardPage(
        dashboardHeader(
          title="Select Data to View or Download",
          titleWidth = 335),
        dashboardSidebar(
          width = 335,
          column(12,align = "center",offset = 0,actionButton("load","Apply Selections"))),
        dashboardBody()
      )
      
      server <- function(input, output) { }
      
      shinyApp(ui, server)
      

      【讨论】:

      • 我觉得左边的距离稍微大一点?
      猜你喜欢
      • 1970-01-01
      • 2020-10-21
      • 2019-10-08
      • 1970-01-01
      • 2020-02-21
      • 2018-12-24
      • 1970-01-01
      • 1970-01-01
      • 2016-12-05
      相关资源
      最近更新 更多