闪亮的复选框按钮宽度和居中

问题描述 投票:0回答:1

我创建了一个带有一些按钮的UI页面,并且checkboxInput按钮有两个问题:

  checkboxInput('comissions', label = "Comissions", width = "10%")

更改width =“X%”不会改变任何内容,“Xpx”也是如此。我怀疑这是由于固定的列宽,但X%的变化适用于其他按钮。

第二个问题是按钮看起来像这样:

enter image description here

我希望它居中,而不是在左栏。

感谢您的帮助,

r shiny shinydashboard
1个回答
1
投票

这是一种使复选框居中的方法,但它需要width = "100%"

library(shiny)

ui <- basicPage(
  fluidRow(
    column(4, 
           sliderInput("costs", "Costs", min = 1, max = 10,  value = 1)),
    column(4, style = "text-align: center;", 
           checkboxInput("comissions", label = "Comissions", width = "100%")),
    column(4, 
           sliderInput("periods", "Number of periods", min = 1, max = 10,  value = 1))
  )
)

server <- function(input, output, session) {}

shinyApp(ui, server)

enter image description here

通过改变宽度,我不知道你期望看到什么?


EDIT

要控制复选框输入周围的空白区域及其垂直对齐方式:

library(shiny)

ui <- basicPage(
  fluidRow(
    column(12,
           div(style = "display: inline-block;", 
               sliderInput("costs", "Costs", min = 1, max = 10,  value = 1)
           ),
           div(style = "display: inline-block; margin-left: 20px; margin-right: 20px; vertical-align: -20px;", 
               checkboxInput("comissions", label = "Comissions", width = "100%")
           ),
           div(style = "display: inline-block;", 
               sliderInput("periods", "Number of periods", min = 1, max = 10,  value = 1)
           )
    )
  )
)

server <- function(input, output, session) {}

shinyApp(ui, server)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.