【问题标题】:How to increase the space between two centered action buttons?如何增加两个居中操作按钮之间的空间?
【发布时间】:2019-01-30 09:57:15
【问题描述】:

我想将两个宽度相等的动作按钮居中,并在它们之间留一些空间。所以我尝试了:

library(shiny)

ui <- fluidPage(
  fluidRow(
    align = "center",
    br(),
    column(
      12,
      actionButton(
        inputId = "ab1",
        label = "Left button",
        style = "width:400px"
      ),
      actionButton(
        inputId = "ab2",
        label = "Right button",
        style = "width:400px"
      )
    ) # column 
  ) # fluidRow
) # fluidPage

server <- function(input, output) {}

shinyApp(ui, server)

这给出了:

如何增加两个按钮之间的间距?在Shiny - How to increase spacing between inline radio buttons?之后我尝试了右键style = "width:400px; margin.left:200px",但是没有任何效果。

编辑:按照 Stephane 的建议,我尝试了:

library(shiny)

ui <- fluidPage(
  fluidRow(
    align = "center",
    br(),
    column(
      6,
      actionButton(
        inputId = "ab1",
        label = "Left button",
        style = "width:400px"
      )
    ),
    column(
      6,
      actionButton(
        inputId = "ab2",
        label = "Right button",
        style = "width:400px"
      )
    ) 
  ) # fluidRow
) # fluidPage

server <- function(input, output) {}

shinyApp(ui, server)

但是,现在两个按钮之间的空间太大了:

如何使它更小,我。 e.如何控制?

【问题讨论】:

  • 您不能使用两个column(6,每个按钮一个,而不是一个column(12,

标签: r shiny


【解决方案1】:

你也可以使用splitLayout:

library(shiny)

ui <- fluidPage(
  fluidRow(
    align = "center",
    br(),
    column(
      12,
      splitLayout(cellWidths = c("30%", "30%"),
                  actionButton(
                    inputId = "ab1",
                    label = "Left button",
                    style = "width:400px"
                  ),
                  actionButton(
                    inputId = "ab2",
                    label = "Right button",
                    style = "width:400px"
                  )
      )
    )
  ) # fluidRow
) # fluidPage

server <- function(input, output) {}

shinyApp(ui, server)

【讨论】:

    【解决方案2】:

    这样,可以吗?

    ui <- fluidPage(
      fluidRow(
        align = "center",
        br(),
        column(
          6,
          actionButton(
            inputId = "ab1",
            label = "Left button",
            style = "width:400px"
          )
        ),
        column(
          6,
          actionButton(
            inputId = "ab2",
            label = "Right button",
            style = "width:400px"
          )
        )  
      ) 
    ) 
    
    server <- function(input, output) {}
    
    shinyApp(ui, server)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 1970-01-01
      • 2016-12-10
      • 2012-01-10
      • 1970-01-01
      • 2014-04-09
      相关资源
      最近更新 更多